private static string BuildMessageBody(Entry entry, Comment comment)
 {
     var builder = new StringBuilder();
     builder.AppendFormat("<p>A comment was posted to the entry: {0}</p>", entry.Title).AppendLine();
     builder.AppendFormat("<p>Author: {0}</p>",  Encode(comment.AuthorName)).AppendLine();
     builder.AppendFormat("<p>Email: {0}</p>",  Encode(comment.AuthorEmail)).AppendLine();
     builder.AppendFormat("<p>Blog: {0}</p>",  Encode(comment.AuthorUrl)).AppendLine();
     builder.AppendFormat("<p>Comment:</p><pre>{0}</pre>", Encode(comment.Body)).AppendLine();
     return builder.ToString();
 }
        public void ReturnsComments()
        {
            var name = "test-" + Guid.NewGuid();

            Database.WithRepository(
                repo =>
                {
                    var entry = new Entry { Name = name, Author = "A1" };
                    var revision = entry.Revise();
                    revision.Body = "Hello";
                    repo.Add(entry);
                    var comment = new Comment
                    {
                        AuthorName = "Test",
                        AuthorEmail = "*****@*****.**",
                        AuthorUrl = "",
                        Body = "Comment",
                        Posted = DateTime.Now,
                        Entry = entry,
                        IsSpam = false
                    };
                    var comment2 = new Comment
                    {
                        AuthorName = "Test2",
                        AuthorEmail = "*****@*****.**",
                        AuthorUrl = "",
                        Body = "Comment2",
                        Posted = DateTime.Now,
                        Entry = entry,
                        IsSpam = false
                    };
                    entry.Comments.Add(comment);
                    entry.Comments.Add(comment2);
                    repo.Add(comment);
                    repo.Add(comment2);
                });

            Database.WithRepository(
                repo =>
                {
                    var result = repo.Find(new GetCommentsQuery(), 0, 1);
                    Assert.AreEqual(1, result.Count);
                    Assert.GreaterOrEqual(result.TotalResults, 2);
                });
        }
        public void Verify(Comment comment)
        {
            var settings = settingsProvider.GetSettings<FunnelWebSettings>();
            var akismet = Connect();
            var akismetComment = new AkismetComment();
            akismetComment.Blog = "http://www.funnelweblog.com";
            akismetComment.CommentAuthor = comment.AuthorName;
            akismetComment.CommentAuthorEmail = comment.AuthorEmail;
            akismetComment.CommentAuthorUrl = comment.AuthorUrl;
            akismetComment.CommentContent = comment.Body;
            akismetComment.CommentType = "comment";

            comment.IsSpam = akismet.CommentCheck(akismetComment);

            if (comment.IsSpam)
                return;

            var naughtyWords = settings.SpamWords.Split('\n').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray();
            comment.IsSpam = naughtyWords.Length > 0 && naughtyWords.Any(x => comment.Body.IndexOf(x, StringComparison.InvariantCultureIgnoreCase) >= 0);
        }
        public override void TestQuery()
        {
            var name = "test-" + Guid.NewGuid();

            Database.WithRepository(
                repo =>
                {
                    var entry = new Entry
                    {
                        Name = name,
                        Author = "A1"
                    };
                    var revision1 = entry.Revise();
                    revision1.Body = "Hello";
                    repo.Add(entry);
                    var comment = new Comment
                    {
                        AuthorName = "Test",
                        AuthorEmail = "*****@*****.**",
                        AuthorUrl = "",
                        Body = "Comment",
                        Posted = DateTime.Now,
                        Entry = entry
                    };
                    entry.Comments.Add(comment);
                    repo.Add(comment);
                });

            Database.WithRepository(
                repo =>
                {
                    var entry = repo.FindFirst(new EntryByNameQuery(name));
                    Assert.AreEqual("A1", entry.Author);
                    Assert.AreEqual("Test", entry.Comments.First().AuthorName);
                });
        }
Beispiel #5
0
 public virtual Comment Comment()
 {
     var comment = new Comment
     {
         Entry = this,
         Posted = DateTime.UtcNow
     };
     Comments.Add(comment);
     CommentCount = Comments.Count;
     return comment;
 }
Beispiel #6
0
 public CommentPostedEvent(Entry entry, Comment comment)
 {
     this.entry = entry;
     this.comment = comment;
 }