support comment without owner or parent id

This commit is contained in:
Yann Esposito (Yogsototh) 2019-06-19 00:08:10 +02:00
parent ee456f7c11
commit 5d4c6bf200
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -250,17 +250,15 @@ instance FormI.FromHttpApiData MUserId where
if Text.null txt if Text.null txt
then return (MUserId Nothing) then return (MUserId Nothing)
else case UUID.fromText txt of else case UUID.fromText txt of
Nothing -> Left $ "Parent ID is not an UUID (" <> txt <> ")" Nothing -> pure (MUserId Nothing)
Just uuid -> return (MUserId (Just (UserId (toS uuid)))) Just uuid -> pure (MUserId (Just (UserId (toS uuid))))
instance FormI.FromHttpApiData ParentId where instance FormI.FromHttpApiData ParentId where
parseUrlPiece s = do parseUrlPiece s = do
txt <- FormI.parseUrlPiece s txt <- FormI.parseUrlPiece s
if Text.null txt if Text.null txt
then return (ParentId Nothing) then return (ParentId Nothing)
else case UUID.fromText txt of else return (ParentId (UUID.fromText txt))
Nothing -> Left $ "Parent ID is not an UUID (" <> txt <> ")"
Just uuid -> return (ParentId (Just uuid))
instance FormI.FromHttpApiData Slug where parseUrlPiece = fmap Slug . FormI.parseUrlPiece instance FormI.FromHttpApiData Slug where parseUrlPiece = fmap Slug . FormI.parseUrlPiece
instance FormI.FromHttpApiData Content where parseUrlPiece = fmap Content . FormI.parseUrlPiece instance FormI.FromHttpApiData Content where parseUrlPiece = fmap Content . FormI.parseUrlPiece