Inheritance: IComment
Exemplo n.º 1
0
 private AkismetComment ConvertToAkismetComment(IFeedback feedback)
 {
     System.Net.IPAddress ipAddress = System.Net.IPAddress.None;
     if (feedback.AuthorIPAddress != null)
     {
         try
         {
             ipAddress = System.Net.IPAddress.Parse(feedback.AuthorIPAddress);
         }
         catch(FormatException){}
     }
     AkismetComment comment = new AkismetComment(ipAddress, feedback.AuthorUserAgent);
     comment.Author = feedback.Author;
     comment.AuthorEmail = feedback.AuthorEmail;
     if (feedback.AuthorHomepage != null && feedback.AuthorHomepage.Length > 0)
     {
         try
         {
             comment.AuthorUrl = new Uri(feedback.AuthorHomepage);
         }
         catch(UriFormatException){}
     }
     comment.Content = feedback.Content;
     comment.Referer = feedback.Referer;
     if (feedback.TargetEntryId != null & feedback.TargetEntryId.Trim().Length > 0)
     {
         try
         {
             comment.Permalink = new Uri(SiteUtilities.GetPermaLinkUrl(feedback.TargetEntryId));
         }
         catch(UriFormatException){}
     }
     comment.CommentType = feedback.FeedbackType;
     return comment;
 }
Exemplo n.º 2
0
        public Comment ConvertToAkismetItem(FeedbackItem feedback)
        {
            var comment = new Comment(feedback.IpAddress, feedback.UserAgent) { Author = feedback.Author ?? string.Empty, AuthorEmail = feedback.Email };
            if (feedback.SourceUrl != null)
            {
                comment.AuthorUrl = feedback.SourceUrl;
            }
            comment.Content = feedback.Body;
            comment.Referrer = feedback.Referrer;

            var feedbackUrl = _urlHelper.FeedbackUrl(feedback);
            if (feedbackUrl != null)
            {
                Uri permalink = feedbackUrl.ToFullyQualifiedUrl(_blog);
                if (permalink != null)
                {
                    comment.Permalink = permalink;
                }
            }

            comment.CommentType = feedback.FeedbackType.ToString().ToLower(CultureInfo.InvariantCulture);
            return comment;
        }
        private AkismetComment ConvertToAkismetComment(IFeedback feedback)
        {
            System.Net.IPAddress ipAddress = System.Net.IPAddress.None;
            if (feedback.AuthorIPAddress != null)
            {
                try
                {
                    ipAddress = System.Net.IPAddress.Parse(feedback.AuthorIPAddress);
                }
                catch (FormatException) {}
            }
            AkismetComment comment = new AkismetComment(ipAddress, feedback.AuthorUserAgent);

            comment.Author      = feedback.Author;
            comment.AuthorEmail = feedback.AuthorEmail;
            if (feedback.AuthorHomepage != null && feedback.AuthorHomepage.Length > 0)
            {
                try
                {
                    comment.AuthorUrl = new Uri(feedback.AuthorHomepage);
                }
                catch (UriFormatException) {}
            }
            comment.Content = feedback.Content;
            comment.Referer = feedback.Referer;
            if (feedback.TargetEntryId != null & feedback.TargetEntryId.Trim().Length > 0)
            {
                try
                {
                    //TODO: comeback
                    //comment.Permalink = new Uri(SiteUtilities.GetPermaLinkUrl(feedback.TargetEntryId));
                }
                catch (UriFormatException) {}
            }
            comment.CommentType = feedback.FeedbackType;
            return(comment);
        }
Exemplo n.º 4
0
        public void CanSetAndGetCommentProperties()
        {
            var comment = new Comment(IPAddress.Loopback, "Test");
            Assert.AreEqual("Test", comment.UserAgent);
            Assert.AreEqual(IPAddress.Loopback, comment.IPAddress);

            UnitTestHelper.AssertSimpleProperties(comment);

            comment.ServerEnvironmentVariables.Add("SomeVar", "SomeVal");
            Assert.AreEqual(1, comment.ServerEnvironmentVariables.Count);
        }