Commit ca590d7a authored by wolftune's avatar wolftune Committed by Mitchell Rosen

changed "moderated" to "approved" (more accurate term)

we should use "moderated" only to mean it went through moderation
process, but not to assume that means approval
parent 9dcad5c3
......@@ -435,12 +435,12 @@ postNewComment mparent_id (Entity user_id user) discussion_id make_permissions_m
(form, _) <- generateFormPost (commentForm (maybe "New Topic" (const "Reply") mparent_id) (Just contents))
now <- liftIO getCurrentTime
let (moderated_ts, moderated_by) = if userIsEstablished user
let (approved_ts, approved_by) = if userIsEstablished user
then (Just now, Just user_id)
else (Nothing, Nothing)
comment = Entity
(Key $ PersistInt64 0)
(Comment now moderated_ts moderated_by discussion_id mparent_id user_id contents depth)
(Comment now approved_ts approved_by discussion_id mparent_id user_id contents depth)
max_depth <- getMaxDepthDefault 0
......
......@@ -167,7 +167,7 @@ postWikiR project_handle target = do
, "(this ticket was automatically generated)"
]
comment_id <- lift $ insert =<< makeModeratedComment user_id (wikiPageDiscussion page) Nothing comment_body 0
comment_id <- lift $ insert =<< makeApprovedComment user_id (wikiPageDiscussion page) Nothing comment_body 0
lift $ insert_ $ Ticket now now "edit conflict" comment_id
......
......@@ -16,7 +16,7 @@ module Model.Comment
, commentIsOddDepth
, commentIsTopLevel
, makeCommentUsersSet
, makeModeratedComment
, makeApprovedComment
, newClosedCommentClosure
, newRetractedCommentClosure
-- Database actions
......@@ -126,7 +126,7 @@ addMaxDepth (MaxDepth x) y = MaxDepth (x + y)
-- Utility functions
commentIsApproved :: Comment -> Bool
commentIsApproved = isJust . commentModeratedTs
commentIsApproved = isJust . commentApprovedTs
commentIsTopLevel :: Comment -> Bool
commentIsTopLevel = (== 0) . commentDepth
......@@ -178,9 +178,9 @@ newCommentClosure :: MonadIO m => ClosureType -> UserId -> Markdown -> CommentId
newCommentClosure closure_type user_id reason comment_id =
(\now -> CommentClosure now user_id closure_type reason comment_id) `liftM` liftIO getCurrentTime
-- | Construct a comment, auto-moderated by 'this' User (because they are established).
makeModeratedComment :: MonadIO m => UserId -> DiscussionId -> Maybe CommentId -> Markdown -> Int -> m Comment
makeModeratedComment user_id discussion_id parent_comment comment_text depth = do
-- | Construct a comment, auto-approved by 'this' User (because they are established).
makeApprovedComment :: MonadIO m => UserId -> DiscussionId -> Maybe CommentId -> Markdown -> Int -> m Comment
makeApprovedComment user_id discussion_id parent_comment comment_text depth = do
now <- liftIO getCurrentTime
return $ Comment
now
......@@ -205,8 +205,8 @@ approveCommentDB user_id comment_id comment = do
-- Do an in-memory adjustment of the comment with exactly the same changes
-- as 'upd' below (so we can avoid hitting the database).
let updated_comment = comment
{ commentModeratedTs = Just now
, commentModeratedBy = Just user_id
{ commentApprovedTs = Just now
, commentApprovedBy = Just user_id
}
lift $ do
updateComment now
......@@ -215,8 +215,8 @@ approveCommentDB user_id comment_id comment = do
where
updateComment now =
update $ \c -> do
set c [ CommentModeratedTs =. val (Just now)
, CommentModeratedBy =. val (Just user_id)
set c [ CommentApprovedTs =. val (Just now)
, CommentApprovedBy =. val (Just user_id)
]
where_ (c ^. CommentId ==. val comment_id)
......@@ -271,11 +271,11 @@ insertCommentDB :: Maybe UTCTime
-> Markdown
-> Int
-> SDB CommentId
insertCommentDB mmoderated_ts mmoderated_by mk_event created_ts discussion_id mparent_id user_id text depth = do
insertCommentDB mapproved_ts mapproved_by mk_event created_ts discussion_id mparent_id user_id text depth = do
let comment = Comment
created_ts
mmoderated_ts
mmoderated_by
mapproved_ts
mapproved_by
discussion_id
mparent_id
user_id
......@@ -493,7 +493,7 @@ fetchCommentCommentTagsInDB comment_ids = fmap (map entityVal) $
where_ (ct ^. CommentTagComment `in_` valList comment_ids)
return ct
-- | Get a Comment's descendants' ids (don't filter hidden or unmoderated comments).
-- | Get a Comment's descendants' ids (don't filter hidden or unapproved comments).
fetchCommentAllDescendantsDB :: CommentId -> DB [CommentId]
fetchCommentAllDescendantsDB = fmap (map unValue) . select . querCommentDescendants
......
......@@ -41,7 +41,7 @@ exprCommentApproved :: ExprCommentCond
exprCommentApproved = not_ . exprCommentUnapproved
exprCommentUnapproved :: ExprCommentCond
exprCommentUnapproved c = isNothing (c ^. CommentModeratedTs)
exprCommentUnapproved c = isNothing (c ^. CommentApprovedTs)
exprCommentFlagged :: ExprCommentCond
exprCommentFlagged c = c ^. CommentId `in_` flaggedCommentIds
......
......@@ -9,7 +9,7 @@ snowdriftEventNewestToOldest :: SnowdriftEvent -> SnowdriftEvent -> Ordering
snowdriftEventNewestToOldest x y = compare (snowdriftEventTime y) (snowdriftEventTime x)
snowdriftEventTime :: SnowdriftEvent -> UTCTime
snowdriftEventTime (ECommentPosted _ Comment{..}) = fromMaybe commentCreatedTs commentModeratedTs
snowdriftEventTime (ECommentPosted _ Comment{..}) = fromMaybe commentCreatedTs commentApprovedTs
snowdriftEventTime (ECommentPending _ Comment{..}) = commentCreatedTs
snowdriftEventTime (ENotificationSent _ Notification{..}) = notificationCreatedTs
snowdriftEventTime (EWikiEdit _ WikiEdit{..}) = wikiEditTs
......
......@@ -146,7 +146,7 @@ updateUserDB user_id UserUpdate{..} = do
-- void (insertMany new_prefs)
-- | Establish a user, given their eligible-timestamp and reason for
-- eligibility. Mark all unmoderated comments of theirs as moderated.
-- eligibility. Mark all unapproved comments of theirs as approved.
establishUserDB :: UserId -> UTCTime -> Text -> DB ()
establishUserDB user_id elig_time reason = do
est_time <- liftIO getCurrentTime
......@@ -161,8 +161,8 @@ establishUserDB user_id elig_time reason = do
approveUnapprovedComments :: UTCTime -> DB ()
approveUnapprovedComments est_time =
update $ \c -> do
set c [ CommentModeratedTs =. just (val est_time)
, CommentModeratedBy =. just (val user_id)
set c [ CommentApprovedTs =. just (val est_time)
, CommentApprovedBy =. just (val user_id)
]
where_ $
c ^. CommentUser ==. val user_id &&.
......
......@@ -71,9 +71,9 @@ getAllWikiComments mviewer_id project_id latest_comment_id since limit_num = do
where_ $
wp ^. WikiPageId `in_` valList pages_ids &&.
c ^. CommentId <=. val latest_comment_id &&.
c ^. CommentModeratedTs >=. just (val since) &&.
c ^. CommentApprovedTs >=. just (val since) &&.
exprCommentProjectPermissionFilter mviewer_id (val project_id) c
orderBy [desc (c ^. CommentModeratedTs)]
orderBy [desc (c ^. CommentApprovedTs)]
limit limit_num
return c
......@@ -84,8 +84,8 @@ getAllWikiComments mviewer_id project_id latest_comment_id since limit_num = do
on_ (c ^. CommentDiscussion ==. wp ^. WikiPageDiscussion)
where_ $
wp ^. WikiPageId `in_` valList pages_ids &&.
c ^. CommentModeratedTs <. just (val since) &&.
c ^. CommentApprovedTs <. just (val since) &&.
exprCommentProjectPermissionFilter mviewer_id (val project_id) c
orderBy [desc (c ^. CommentModeratedTs)]
orderBy [desc (c ^. CommentApprovedTs)]
limit lim
return c
......@@ -82,7 +82,7 @@ notificationEventHandler (EDeletedPledge _ _ _ _) = return ()
-- | Handler in charge of inserting events (stripped down) into a separate table for each type.
eventInserterHandler :: SnowdriftEvent -> Daemon ()
-- If an unapproved comment is sent as an ECommentPosted event, bad things will happen (fromJust).
eventInserterHandler (ECommentPosted comment_id Comment{..}) = runDB (insert_ (EventCommentPosted (fromJust commentModeratedTs) comment_id))
eventInserterHandler (ECommentPosted comment_id Comment{..}) = runDB (insert_ (EventCommentPosted (fromJust commentApprovedTs) comment_id))
eventInserterHandler (ECommentPending comment_id Comment{..}) = runDB (insert_ (EventCommentPending commentCreatedTs comment_id))
eventInserterHandler (ENotificationSent notif_id Notification{..}) = runDB (insert_ (EventNotificationSent notificationCreatedTs notif_id))
eventInserterHandler (EWikiPage wiki_page_id WikiPage{..}) = runDB (insert_ (EventWikiPage wikiPageCreatedTs wiki_page_id))
......
......@@ -123,8 +123,8 @@ renderCommentPostedOnUnknownDiscussionEvent :: CommentId -> Comment -> Widget
renderCommentPostedOnUnknownDiscussionEvent comment_id comment =
[whamlet|
<div .event>
$maybe moderated_ts <- commentModeratedTs comment
^{renderTime moderated_ts}
$maybe approved_ts <- commentApprovedTs comment
^{renderTime approved_ts}
$nothing
^{renderTime $ commentCreatedTs comment}
somehow, this
......
......@@ -215,10 +215,10 @@ Comment
createdTs UTCTime
-- "Unestablished" users may still make comments, but they must be approved
-- by a moderator. "Established" users' comments are marked as moderated by
-- by a moderator. "Established" users' comments are marked as approved by
-- themselves (though this does not mean they are a moderator).
moderatedTs UTCTime Maybe
moderatedBy UserId Maybe
approvedTs UTCTime Maybe
approvedBy UserId Maybe
discussion DiscussionId
parent CommentId Maybe
......
This diff is collapsed.
ALTER TABLE "comment" RENAME COLUMN "moderated_ts" TO "approved_ts";
ALTER TABLE "comment" RENAME COLUMN "moderated_by" TO "approved_by";
ALTER TABLE "comment" ADD CONSTRAINT "comment_approved_by_fkey" FOREIGN KEY("approved_by") REFERENCES "user"("id");
\ No newline at end of file
......@@ -7,8 +7,8 @@
<a href="@{UserR user_id}">
#{userDisplayName (Entity user_id user)}
<div .comment-head>
$maybe moderated_ts <- commentModeratedTs comment
^{renderTime moderated_ts}
$maybe approved_ts <- commentApprovedTs comment
^{renderTime approved_ts}
$nothing
^{renderTime $ commentCreatedTs comment}
<div .comment-head :is_preview:.preview>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment