packages feed

mattermost-api 50200.7.0 → 50200.8.0

raw patch · 6 files changed

+56/−30 lines, 6 filesdep ~HTTPPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: HTTP

API changes (from Hackage documentation)

- Network.Mattermost.Types: instance Network.Mattermost.Types.HasId Network.Mattermost.Types.Command Network.Mattermost.Types.CommandId
+ Network.Mattermost.Endpoints: mmListCommandsForTeam :: TeamId -> Bool -> Session -> IO (Seq Command)
+ Network.Mattermost.WebSocket.Types: WMUnknownEvent :: Text -> WebsocketEventType
- Network.Mattermost.Types: Command :: CommandId -> Token -> ServerTime -> ServerTime -> ServerTime -> UserId -> TeamId -> Text -> Text -> Text -> Text -> Bool -> Text -> Text -> Text -> Text -> Text -> Command
+ Network.Mattermost.Types: Command :: Maybe CommandId -> Text -> ServerTime -> ServerTime -> ServerTime -> Maybe UserId -> Maybe TeamId -> Text -> Text -> Text -> Text -> Bool -> Text -> Text -> Text -> Text -> Text -> Command
- Network.Mattermost.Types: [commandCreatorId] :: Command -> UserId
+ Network.Mattermost.Types: [commandCreatorId] :: Command -> Maybe UserId
- Network.Mattermost.Types: [commandId] :: Command -> CommandId
+ Network.Mattermost.Types: [commandId] :: Command -> Maybe CommandId
- Network.Mattermost.Types: [commandTeamId] :: Command -> TeamId
+ Network.Mattermost.Types: [commandTeamId] :: Command -> Maybe TeamId
- Network.Mattermost.Types: [commandToken] :: Command -> Token
+ Network.Mattermost.Types: [commandToken] :: Command -> Text

Files

CHANGELOG.md view
@@ -2,6 +2,20 @@ 50200.7.0 ========= +API changes:+ * Added a `WMUnknownEvent` constructor to the `WebsocketEventType` data+   type to hold unknown event types to avoid parse failures for new+   event types.+ * Added `mmListCommandsForTeam` to get commands for a team and+   implemented a JSON parser for the `Command` type.++Package changes:+ * Upgraded to HTTP 4000.3.15 to get an `Eq` instance fix for HTTP+   header name comparisons.++50200.7.0+=========+  * Added `mmUpdateChannelNotifications` and fixed the JSON encoding of    the `ChannelNotifyProps` type. 
mattermost-api.cabal view
@@ -1,5 +1,5 @@ name:                mattermost-api-version:             50200.7.0+version:             50200.8.0 synopsis:            Client API for Mattermost chat system  description:         Client API for Mattermost chat system.  Mattermost is a@@ -11,9 +11,8 @@  license:             BSD3 license-file:        LICENSE-author:              Jason Dagit-maintainer:          dagitj@gmail.com-copyright:           2016-2017 Jason Dagit, Getty Ritter, Jonathan Daugherty+maintainer:          matterhorn@galois.com+copyright:           2016-2020 Jason Dagit, Getty Ritter, Jonathan Daugherty category:            Web build-type:          Simple extra-doc-files:     README.md,@@ -60,7 +59,9 @@                      , binary >= 0.8.1                      , bytestring                      , process-                     , HTTP+                     -- We depend on this lower bound to get a fix for+                     -- https://github.com/haskell/HTTP/issues/128+                     , HTTP >= 4000.3.15                      , http-media                      , network-uri                      , modern-uri
src/Network/Mattermost/Connection.hs view
@@ -180,17 +180,8 @@         Left _ ->           throwIO (HTTPResponseException ("Server returned unexpected " ++ show code ++ " response")) --- NOTE: At least as of HTTP-4000.3.14, custom header names are matched--- case-sensitively when looking them up in responses. This is a bug--- (reported at https://github.com/haskell/HTTP/issues/128) and in--- the mean time we use our own header-matching implementation. findHeader :: HTTP.HeaderName -> [HTTP.Header] -> Maybe String-findHeader n hs = HTTP.hdrValue <$> listToMaybe (filter (matchHeader n) hs)--matchHeader :: HTTP.HeaderName -> HTTP.Header -> Bool-matchHeader (HTTP.HdrCustom a) (HTTP.Header (HTTP.HdrCustom b) _) =-    (toLower <$> a) == (toLower <$> b)-matchHeader a (HTTP.Header b _) = a == b+findHeader n hs = HTTP.hdrValue <$> listToMaybe (filter ((== n) . HTTP.hdrName) hs)  rateLimitLimitHeader :: HTTP.HeaderName rateLimitLimitHeader = HTTP.HdrCustom "X-RateLimit-Limit"
src/Network/Mattermost/Endpoints.hs view
@@ -333,11 +333,12 @@ -- -- | List commands for a team. -- -- -- --   /Permissions/: @manage_slash_commands@ if need list custom commands.--- mmListCommandsForTeam :: TeamId -> Maybe Text -> Session -> IO (Seq Command)--- mmListCommandsForTeam teamId customOnly =---   inGet (printf "/commands?%s" (mkQueryString [ Just ("team_id", T.unpack (idString teamId)) , sequence ("custom_only", fmap T.unpack customOnly) ])) noBody jsonResponse--+mmListCommandsForTeam :: TeamId -> Bool -> Session -> IO (Seq Command)+mmListCommandsForTeam teamId customOnly =+    let pairs = [ Just ("team_id", T.unpack (idString teamId))+                , Just ("custom_only", if customOnly then "true" else "false")+                ]+    in inGet (printf "/commands?%s" (mkQueryString pairs)) noBody jsonResponse  -- * Compliance 
src/Network/Mattermost/Types.hs view
@@ -985,13 +985,13 @@  data Command   = Command-  { commandId               :: CommandId-  , commandToken            :: Token+  { commandId               :: Maybe CommandId+  , commandToken            :: Text   , commandCreateAt         :: ServerTime   , commandUpdateAt         :: ServerTime   , commandDeleteAt         :: ServerTime-  , commandCreatorId        :: UserId-  , commandTeamId           :: TeamId+  , commandCreatorId        :: Maybe UserId+  , commandTeamId           :: Maybe TeamId   , commandTrigger          :: Text   , commandMethod           :: Text   , commandUsername         :: Text@@ -1004,6 +1004,28 @@   , commandURL              :: Text   } deriving (Read, Show, Eq) +instance A.FromJSON Command where+    parseJSON = A.withObject "command" $ \o ->+        Command <$> (maybeFail $ o A..: "id")+                <*> o A..: "token"+                <*> (timeFromServer <$> (o A..: "create_at"))+                <*> (timeFromServer <$> (o A..: "update_at"))+                <*> (timeFromServer <$> (o A..: "delete_at"))+                <*> (maybeFail $ o A..: "creator_id")+                <*> (maybeFail $ o A..: "team_id")+                <*> o A..: "trigger"+                <*> o A..: "method"+                <*> o A..: "username"+                <*> o A..: "icon_url"+                <*> o A..: "auto_complete"+                <*> o A..: "auto_complete_desc"+                <*> o A..: "auto_complete_hint"+                <*> o A..: "display_name"+                <*> o A..: "description"+                <*> o A..: "url"++instance A.ToJSON Command where toJSON = error "to command"+ newtype CommandId = CmdI { unCmdI :: Id }   deriving (Read, Show, Eq, Ord, Hashable, ToJSON, ToJSONKey, FromJSONKey, FromJSON) @@ -1011,9 +1033,6 @@   toId   = unCmdI   fromId = CmdI -instance HasId Command CommandId where-  getId = commandId- instance PrintfArg CommandId where   formatArg = formatArg . idString @@ -1351,8 +1370,6 @@  instance A.ToJSON User where toJSON = error "to user" instance A.ToJSON Team where toJSON = error "to team"-instance A.FromJSON Command where parseJSON = error "from command"-instance A.ToJSON Command where toJSON = error "to command"   -- --
src/Network/Mattermost/WebSocket/Types.hs view
@@ -76,6 +76,7 @@   | WMPluginStatusesChanged   | WMPluginEnabled   | WMPluginDisabled+  | WMUnknownEvent T.Text   deriving (Read, Show, Eq, Ord)  instance FromJSON WebsocketEventType where@@ -113,7 +114,7 @@     "plugin_statuses_changed" -> return WMPluginStatusesChanged     "plugin_enabled"     -> return WMPluginEnabled     "plugin_disabled"    -> return WMPluginDisabled-    _                    -> fail ("Unknown websocket message: " ++ show s)+    _                    -> return $ WMUnknownEvent s  instance ToJSON WebsocketEventType where   toJSON WMTyping                  = "typing"@@ -149,6 +150,7 @@   toJSON WMPluginStatusesChanged   = "plugin_statuses_changed"   toJSON WMPluginEnabled           = "plugin_enabled"   toJSON WMPluginDisabled          = "plugin_disabled"+  toJSON (WMUnknownEvent s)        = toJSON s  --