//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Xml;
using System.Collections;
using CommunityServer.Components;
using CommunityServer.Configuration;

namespace CommunityServer.Blogs.Components
{
	/// <summary>
	/// This CS Job deletes spam comments after they've been around for xxx days.
	/// </summary>
	public class DeleteStaleSpamCommentsJob : IJob
	{
		private int expirationDays = 30;

		public DeleteStaleSpamCommentsJob()
		{
		}

		public void Execute(XmlNode node)
		{
			try { expirationDays = int.Parse(node.Attributes["expirationDays"].Value); }
			catch { }

			SiteSettingsManager.IterateSiteSettings(new SiteSettingsListIterator(DeleteStaleSpamComments));
		}

		public void DeleteStaleSpamComments(int settingsID)
		{
			WeblogDataProvider.Instance().DeleteStaleSpamComments(settingsID, expirationDays);
		}
	}
}
