Exemplo n.º 1
0
        public bool SendCommentPostedReply(Post post, string twitterUserName, string displayName)
        {
            var pageUrl   = _tinyUrlService.Tinyfy(_urlResolver.PublishedPost(new PostDisplay(post)));
            var pageTitle = post.Title;

            if (pageTitle.Length > 50)
            {
                pageTitle = pageTitle.Substring(0, 47) + "...";
            }

            var message = "New comment from {0} in {1} - {2}".ToFormat(displayName, pageTitle, pageUrl);

            List <string> twitterUserNames = post.GetComments()
                                             .Where(comment => (!string.IsNullOrEmpty(comment.TwitterUserName) && comment.TwitterUserName != twitterUserName))
                                             .Select(x => x.TwitterUserName)
                                             .ToList();

            twitterUserNames.Add(post.User.TwitterUserName);

            twitterUserNames.Distinct().Each(userName =>
                                             _twitterClient.SendReply(_siteConfiguration.TwitterUserName, _siteConfiguration.TwitterPassword, userName, message));

            return(true);
        }