void ga_AfterUpdate(DataBuddyBase dataObject, EventArgs e) { Post post = dataObject as Post; if (post != null) { // Check that post // 1. Is Published // 2. The current verison is set to be published // 3. Was not published within the last 10 seconds (some plugins update the post immediately after it is created, // which can cause double trackbacks/pings) if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddSeconds(-10.0)) <= 0) { // Blog Pings if (EnablePings) { XmlRpcPings.SendPings(post, PingUrls); } // Check for links to send Trackbacks & Pingbacks if (EnableTrackbacks) { LinkParser.CheckPost(post); } } } }
void ga_AfterInsert(DataBuddyBase dataObject, EventArgs e) { Post post = dataObject as Post; if (post != null) { // Check that post // 1. Is Published // 2. The current verison is set to be published // 3. Is not a future dated post if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddMinutes(1.0)) <= 0) { // Blog Pings if (EnablePings) { XmlRpcPings.SendPings(post, PingUrls); } // Check for links to send Trackbacks & Pingbacks if (EnableTrackbacks) { LinkParser.CheckPost(post); } } } }
public static void SendPings(Post post, string pingUrls) { // Split ping urls into string array string[] pingUrlsArray = pingUrls.Split('\n'); // Gather information to pass to ping service(s) string name = SiteSettings.Get().Title; string url = post.Category.IsUncategorized ? new Macros().FullUrl(new Urls().Home) : new Macros().FullUrl(post.Category.Url); string feedUrl = SiteSettings.Get().ExternalFeedUrl ?? new Macros().FullUrl(VirtualPathUtility.ToAbsolute("~/feed/")); XmlRpcPings pinger = new XmlRpcPings(name, url, feedUrl, pingUrlsArray); ManagedThreadPool.QueueUserWorkItem(new WaitCallback(pinger.SendPings)); }