diff --git a/app/controllers/AdminController.asp b/app/controllers/AdminController.asp index 1b3ab8d..6226d55 100644 --- a/app/controllers/AdminController.asp +++ b/app/controllers/AdminController.asp @@ -58,6 +58,18 @@ Class AdminController_Class <% End Sub + '--------------------------------------------------------------- + ' Action: Comments + '--------------------------------------------------------------- + Public Sub Comments() + m_title = "Manage Comments" + Dim comments + Set comments = CommentsRepository().Find(Empty, "CreatedDate") + %> + + <% + End Sub + '--------------------------------------------------------------- ' Action: AIPrompt '--------------------------------------------------------------- @@ -144,6 +156,41 @@ Class AdminController_Class Response.Redirect "/admin/posts" End Sub + '--------------------------------------------------------------- + ' Action: ApproveComment + '--------------------------------------------------------------- + Public Sub ApproveComment(ByVal id) + UpdateCommentApproval id, 1, "Comment approved." + End Sub + + '--------------------------------------------------------------- + ' Action: UnapproveComment + '--------------------------------------------------------------- + Public Sub UnapproveComment(ByVal id) + UpdateCommentApproval id, 0, "Comment unapproved." + End Sub + + '--------------------------------------------------------------- + ' Action: DeleteComment + '--------------------------------------------------------------- + Public Sub DeleteComment(ByVal id) + Dim comment + On Error Resume Next + Set comment = CommentsRepository().FindByID(id) + If Err.Number <> 0 Then + Err.Clear + On Error GoTo 0 + Flash().AddError "Comment not found." + Response.Redirect "/admin/comments" + Exit Sub + End If + On Error GoTo 0 + + CommentsRepository().Delete id + Flash().Success = "Comment deleted." + Response.Redirect "/admin/comments" + End Sub + '--------------------------------------------------------------- ' Action: GenerateAIContent '--------------------------------------------------------------- @@ -241,6 +288,25 @@ Class AdminController_Class If parsed.data.Exists("body") Then generatedBody = Trim(CStr(parsed.data.Item("body"))) End Sub + Private Sub UpdateCommentApproval(ByVal id, ByVal isApproved, ByVal successMessage) + Dim comment + On Error Resume Next + Set comment = CommentsRepository().FindByID(id) + If Err.Number <> 0 Then + Err.Clear + On Error GoTo 0 + Flash().AddError "Comment not found." + Response.Redirect "/admin/comments" + Exit Sub + End If + On Error GoTo 0 + + comment.IsApproved = isApproved + CommentsRepository().Update comment + Flash().Success = successMessage + Response.Redirect "/admin/comments" + End Sub + Private Function HttpPostJson(ByVal url, ByVal apiKey, ByVal payload) Dim http Set http = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")