about summary refs log tree commit diff
path: root/src/BlogDB.hs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@googlemail.com>2012-04-04T02·10+0200
committerVincent Ambo <tazjin@googlemail.com>2012-04-04T02·10+0200
commitd15a01007ee50d5b7c75a186b6c4d72fc47b45b7 (patch)
tree52b620d165357fab8fe12cba484b86af4e6d312c /src/BlogDB.hs
parent533463511fea14385f7e35498f52dd7199e1ce54 (diff)
* comment deletion (this doesn't look nice, but nobody except for me sees the admin page so I DON'T CARE :D)
Diffstat (limited to 'src/BlogDB.hs')
-rw-r--r--src/BlogDB.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/BlogDB.hs b/src/BlogDB.hs
index ea574c70842b..611a08914a09 100644
--- a/src/BlogDB.hs
+++ b/src/BlogDB.hs
@@ -150,6 +150,14 @@ addComment eId c =
 	   put $ b { blogEntries = IxSet.updateIx eId newEntry blogEntries }
 	   return newEntry
 
+deleteComment :: EntryId -> UTCTime -> Update Blog Entry
+deleteComment eId cDate =
+   do b@Blog{..} <- get
+      let (Just e) = getOne $ blogEntries @= eId
+      let newEntry = e {comments = filter (\c -> cdate c /= cDate) (comments e)}
+      put $ b { blogEntries = IxSet.updateIx eId newEntry blogEntries }
+      return newEntry
+
 updateEntry :: Entry -> Update Blog Entry
 updateEntry e = 
     do b@Blog{..} <- get
@@ -210,6 +218,7 @@ hashString = B64.encode .  SHA.hash . B.pack
 $(makeAcidic ''Blog
     [ 'insertEntry
     , 'addComment
+    , 'deleteComment
     , 'updateEntry
     , 'getEntry
     , 'latestEntries