mattermost-api 40000.0.1 → 40000.1.0
raw patch · 4 files changed
+68/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.Mattermost: PreferenceCategoryLast :: PreferenceCategory
+ Network.Mattermost: [minComParentId] :: MinCommand -> Maybe PostId
+ Network.Mattermost: [minComRootId] :: MinCommand -> Maybe PostId
+ Network.Mattermost: mmGetAllChannelDataForUser :: Session -> TeamId -> UserId -> IO (Seq ChannelData)
+ Network.Mattermost: mmGetAllChannelsForUser :: Session -> TeamId -> UserId -> IO (Seq Channel)
+ Network.Mattermost: mmGetAllChannelsWithDataForUser :: Session -> TeamId -> UserId -> IO (HashMap ChannelId ChannelWithData)
+ Network.Mattermost.Types: PreferenceCategoryLast :: PreferenceCategory
+ Network.Mattermost.Types: [minComParentId] :: MinCommand -> Maybe PostId
+ Network.Mattermost.Types: [minComRootId] :: MinCommand -> Maybe PostId
- Network.Mattermost: CommandResponse :: CommandResponseType -> Text -> Text -> Text -> Text -> Seq PostPropAttachment -> CommandResponse
+ Network.Mattermost: CommandResponse :: Maybe CommandResponseType -> Text -> Text -> Text -> Text -> Seq PostPropAttachment -> CommandResponse
- Network.Mattermost: MinCommand :: ChannelId -> Text -> MinCommand
+ Network.Mattermost: MinCommand :: ChannelId -> Text -> Maybe PostId -> Maybe PostId -> MinCommand
- Network.Mattermost: Post :: Maybe PostId -> Maybe PostId -> PostProps -> Text -> Seq FileId -> PostId -> PostType -> Text -> Maybe UTCTime -> Text -> UTCTime -> Maybe UserId -> UTCTime -> Maybe PostId -> ChannelId -> Bool -> Post
+ Network.Mattermost: Post :: Maybe PostId -> Maybe PostId -> PostProps -> Maybe PostId -> Seq FileId -> PostId -> PostType -> Text -> Maybe UTCTime -> Text -> UTCTime -> Maybe UserId -> UTCTime -> Maybe PostId -> ChannelId -> Bool -> Post
- Network.Mattermost: [commandResponseType] :: CommandResponse -> CommandResponseType
+ Network.Mattermost: [commandResponseType] :: CommandResponse -> Maybe CommandResponseType
- Network.Mattermost: [postRootId] :: Post -> Text
+ Network.Mattermost: [postRootId] :: Post -> Maybe PostId
- Network.Mattermost.Lenses: commandResponseTypeL :: Lens' CommandResponse CommandResponseType
+ Network.Mattermost.Lenses: commandResponseTypeL :: Lens' CommandResponse (Maybe CommandResponseType)
- Network.Mattermost.Lenses: postRootIdL :: Lens' Post Text
+ Network.Mattermost.Lenses: postRootIdL :: Lens' Post (Maybe PostId)
- Network.Mattermost.Types: CommandResponse :: CommandResponseType -> Text -> Text -> Text -> Text -> Seq PostPropAttachment -> CommandResponse
+ Network.Mattermost.Types: CommandResponse :: Maybe CommandResponseType -> Text -> Text -> Text -> Text -> Seq PostPropAttachment -> CommandResponse
- Network.Mattermost.Types: MinCommand :: ChannelId -> Text -> MinCommand
+ Network.Mattermost.Types: MinCommand :: ChannelId -> Text -> Maybe PostId -> Maybe PostId -> MinCommand
- Network.Mattermost.Types: Post :: Maybe PostId -> Maybe PostId -> PostProps -> Text -> Seq FileId -> PostId -> PostType -> Text -> Maybe UTCTime -> Text -> UTCTime -> Maybe UserId -> UTCTime -> Maybe PostId -> ChannelId -> Bool -> Post
+ Network.Mattermost.Types: Post :: Maybe PostId -> Maybe PostId -> PostProps -> Maybe PostId -> Seq FileId -> PostId -> PostType -> Text -> Maybe UTCTime -> Text -> UTCTime -> Maybe UserId -> UTCTime -> Maybe PostId -> ChannelId -> Bool -> Post
- Network.Mattermost.Types: [commandResponseType] :: CommandResponse -> CommandResponseType
+ Network.Mattermost.Types: [commandResponseType] :: CommandResponse -> Maybe CommandResponseType
- Network.Mattermost.Types: [postRootId] :: Post -> Text
+ Network.Mattermost.Types: [postRootId] :: Post -> Maybe PostId
Files
- CHANGELOG.md +17/−0
- mattermost-api.cabal +1/−1
- src/Network/Mattermost.hs +39/−1
- src/Network/Mattermost/Types.hs +11/−4
CHANGELOG.md view
@@ -1,4 +1,21 @@ +40000.1.0+=========++API changes:+ * The postRootId of Post is now a Maybe PostId to better reflect the+ actual wire format.+ * MinCommand now has fields for reply parent and root post IDs to+ support replying to posts with commands such as /me.+ * CommandResponse's commandResponseType is now Maybe to permit optional+ types.+ * PreferenceCategory got a new constructor, PreferenceCategoryLast,+ mapping to the "last" preference category.+ * Added functions for bulk fetching for channel/user data:+ * mmGetAllChannelsForUser+ * mmGetAllChannelDataForUser+ * mmGetAllChannelsWithDataForUser+ 40000.0.1 =========
mattermost-api.cabal view
@@ -1,5 +1,5 @@ name: mattermost-api-version: 40000.0.1+version: 40000.1.0 synopsis: Client API for Mattermost chat system description: Client API for Mattermost chat system license: BSD3
src/Network/Mattermost.hs view
@@ -68,6 +68,9 @@ , mmJoinChannel , mmGetTeams , mmGetChannels+, mmGetAllChannelsForUser+, mmGetAllChannelDataForUser+, mmGetAllChannelsWithDataForUser , mmGetMoreChannels , mmGetChannel , mmViewChannel@@ -144,7 +147,8 @@ , encode , eitherDecode )-import Data.Maybe ( maybeToList )+import Data.Maybe ( maybeToList, fromJust )+import qualified Data.Foldable as F import qualified Data.Sequence as Seq import qualified Data.Text as T import Control.Arrow ( left )@@ -314,6 +318,40 @@ (idString teamid) (idString chanid)) return++-- | Get channel/user metadata in bulk.+mmGetAllChannelDataForUser :: Session+ -> TeamId+ -> UserId+ -> IO (Seq.Seq ChannelData)+mmGetAllChannelDataForUser sess teamid userid =+ mmDoRequest sess "mmGetAllChannelDataForUser" $+ printf "/api/v4/users/%s/teams/%s/channels/members"+ (idString userid)+ (idString teamid)++mmGetAllChannelsForUser :: Session+ -> TeamId+ -> UserId+ -> IO (Seq.Seq Channel)+mmGetAllChannelsForUser sess teamid userid =+ mmDoRequest sess "mmGetAllChannelsForUser" $+ printf "/api/v4/users/%s/teams/%s/channels"+ (idString userid)+ (idString teamid)++mmGetAllChannelsWithDataForUser :: Session+ -> TeamId+ -> UserId+ -> IO (HM.HashMap ChannelId ChannelWithData)+mmGetAllChannelsWithDataForUser sess teamid userid = do+ chans <- mmGetAllChannelsForUser sess teamid userid+ datas <- mmGetAllChannelDataForUser sess teamid userid++ let dataMap = HM.fromList $ F.toList $ (\d -> (channelDataChannelId d, d)) <$> datas+ mkPair chan = (getId chan, ChannelWithData chan $ fromJust $ HM.lookup (getId chan) dataMap)++ return $ HM.fromList $ F.toList $ mkPair <$> chans -- | -- route: @\/api\/v3\/teams\/{team_id}\/channels\/view@
src/Network/Mattermost/Types.hs view
@@ -640,7 +640,7 @@ { postPendingPostId :: Maybe PostId , postOriginalId :: Maybe PostId , postProps :: PostProps- , postRootId :: Text+ , postRootId :: Maybe PostId , postFileIds :: Seq FileId , postId :: PostId , postType :: PostType@@ -663,7 +663,7 @@ postPendingPostId <- maybeFail (v .: "pending_post_id") postOriginalId <- maybeFail (v .: "original_id") postProps <- v .: "props"- postRootId <- v .: "root_id"+ postRootId <- maybeFail (v .: "root_id") postFileIds <- (v .: "file_ids") <|> (return mempty) postId <- v .: "id" postType <- v .: "type"@@ -810,12 +810,16 @@ = MinCommand { minComChannelId :: ChannelId , minComCommand :: Text+ , minComParentId :: Maybe PostId+ , minComRootId :: Maybe PostId } deriving (Read, Show, Eq) instance A.ToJSON MinCommand where toJSON MinCommand { .. } = A.object [ "channel_id" .= minComChannelId , "command" .= minComCommand+ , "parent_id" .= minComParentId+ , "root_id" .= minComRootId ] --@@ -863,7 +867,7 @@ data CommandResponse = CommandResponse- { commandResponseType :: CommandResponseType+ { commandResponseType :: Maybe CommandResponseType , commandResponseText :: Text , commandResponseUsername :: Text , commandResponseIconURL :: Text@@ -873,7 +877,7 @@ instance A.FromJSON CommandResponse where parseJSON = A.withObject "CommandResponse" $ \o -> do- commandResponseType <- o .: "response_type"+ commandResponseType <- optional (o .: "response_type") commandResponseText <- o .: "text" commandResponseUsername <- o .: "username" commandResponseIconURL <- o .: "icon_url"@@ -952,6 +956,7 @@ | PreferenceCategoryTheme | PreferenceCategoryAuthorizedOAuthApp | PreferenceCategoryNotifications+ | PreferenceCategoryLast | PreferenceCategoryOther Text deriving (Read, Show, Eq) @@ -965,6 +970,7 @@ "theme" -> PreferenceCategoryTheme "oauth_app" -> PreferenceCategoryAuthorizedOAuthApp "notifications" -> PreferenceCategoryNotifications+ "last" -> PreferenceCategoryLast _ -> PreferenceCategoryOther t instance A.ToJSON PreferenceCategory where@@ -977,6 +983,7 @@ PreferenceCategoryTheme -> "theme" PreferenceCategoryAuthorizedOAuthApp -> "oauth_app" PreferenceCategoryNotifications -> "notifications"+ PreferenceCategoryLast -> "last" PreferenceCategoryOther t -> t data PreferenceName