Ejemplo n.º 1
0
 public CommentProcessorPipeline(IComment commentRepository, ISettings settingsRepository, IAkismetService akismetService, IError error, CommentEntity commentEntity, RequestData requestData)
 {
     _commentRepository = commentRepository;
     _settingsRepository = settingsRepository;
     _akismetService = akismetService;
     _error = error;
     _commentEntity = commentEntity;
     _requestData = requestData;
 }
Ejemplo n.º 2
0
 public static AkismetComment Create(CommentEntity commentEntity, RequestData requestData)
 {
     return new AkismetComment
     {
         Blog = requestData.Blog,
         UserIp = requestData.UserIp,
         UserAgent = requestData.UserAgent,
         Referrer = requestData.Referrer,
         Permalink = null,
         CommentType = "blog",
         CommentAuthor = commentEntity.CommentUserFullName,
         CommentAuthorEmail = commentEntity.CommenterEmail,
         CommentAuthorUrl = commentEntity.CommenterSite,
         CommentContent = commentEntity.CommentContent
     };
 }
Ejemplo n.º 3
0
        public void Can_Process_Comment_When_Akistmet_Is_Enabled_And_Delete_Is_Disabled_Ham()
        {
            var comment = MockObjectFactory.CreateCommentRepository();
            var settings = MockObjectFactory.CreateSettingsRepository(2);
            var akismet = MockObjectFactory.CreateAkismetService();
            var error = MockObjectFactory.CreateErrorLogger();
            var commentEntity = GetHamComment(1001,5);
            var requestData = new RequestData();

            var commentProcessorPipeline = new CommentProcessorPipeline(comment, settings, akismet, error, commentEntity, requestData);
            var akismetStatus = commentProcessorPipeline.ProcessComment();

            Assert.IsFalse(akismetStatus.IsSpam);
            Assert.IsTrue(akismetStatus.IsHam);

            var commentsByPost = comment.GetCommentsByPostID(5);
            Assert.IsNotNull(commentsByPost.First());
            Assert.AreEqual(commentEntity.CommentContent, commentsByPost.First().CommentContent);
        }
Ejemplo n.º 4
0
        public void Can_Process_Comment_When_Akistmet_Is_Enabled_And_Delete_Is_Disabled_Spam()
        {
            var comment = MockObjectFactory.CreateCommentRepository();
            var settings = MockObjectFactory.CreateSettingsRepository(2);
            var akismet = MockObjectFactory.CreateAkismetService();
            var error = MockObjectFactory.CreateErrorLogger();
            var commentEntity = GetSpamComment(1002, 6);
            var requestData = new RequestData();

            var commentProcessorPipeline = new CommentProcessorPipeline(comment, settings, akismet, error, commentEntity, requestData);
            var akismetStatus = commentProcessorPipeline.ProcessComment();

            Assert.IsTrue(akismetStatus.IsSpam);
            Assert.IsFalse(akismetStatus.IsHam);

            var commentsByPost = comment.GetAllComments();
            var commentInQn = commentsByPost.Single(c => c.CommentID == 1002 && c.PostID == 6);
            Assert.IsNotNull(commentInQn);
            Assert.AreEqual(2, commentInQn.CommentStatus);
        }
Ejemplo n.º 5
0
 private RequestData GetRequestData()
 {
     if (Request.UrlReferrer != null)
     {
         var requestData = new RequestData
                               {
                                   Blog = SettingsRepository.BlogAkismetUrl,
                                   UserIp = Request.UserHostAddress,
                                   UserAgent = Request.UserAgent,
                                   Referrer = Request.UrlReferrer.ToString(),
                                   IsAuthenticated = Request.IsAuthenticated
                               };
         return requestData;
     }
     return null;
 }