[mono/monkeywrench] 308d3d3e: Cache IRC notifications to not spam channels with the same notification several times.
"Rolf Bjarne Kvinge (
[email protected] )" <
[email protected] >
Wed, 2 Oct 2013 20:54:41 +0000
Newsgroups
gmane.comp.gnome.mono.patches
Message-ID
<000001417af37ef1-c1314e6a-7d1c-4b2f-9544-4abc68340dad-000000@email.amazonses.com>
Branch: refs/heads/master
Home: https://github.com/mono/monkeywrench
Compare: https://github.com/mono/monkeywrench/compare/b7133d56660a...308d3d3ef3f0
Commit: 308d3d3ef3f09b54573298e6b757e44fb061696c
Author: Rolf Bjarne Kvinge <[email protected] > (rolfbjarne)
Date: 2013-10-02 20:51:36 GMT
URL: https://github.com/mono/monkeywrench/commit/308d3d3ef3f09b54573298e6b757e44fb061696c
Cache IRC notifications to not spam channels with the same notification several times.
Changed paths:
M MonkeyWrench.Web.UI/web.config
M MonkeyWrench.Web.WebService/Makefile
M MonkeyWrench.Web.WebService/MonkeyWrench.Web.WebService.csproj
M MonkeyWrench.Web.WebService/Notifications.cs
M MonkeyWrench.Web.WebService/web.config
Modified: MonkeyWrench.Web.UI/web.config
===================================================================
@@ -1,10 +1,19 @@
-<?xml version="1.0"?>
-<configuration>
- <configSections/>
- <system.web>
- <customErrors mode="Off"/>
- <compilation debug="true" targetFramework="4.0"/>
- <httpRuntime executionTimeout="300" requestValidationMode="2.0"/>
- <pages enableViewState="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
- </system.web>
+<?xml version="1.0"?>
+<configuration>
+ <configSections />
+ <system.web>
+ <customErrors mode="Off" />
+ <compilation debug="true" targetFramework="4.0">
+ <assemblies>
+ <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ </assemblies>
+ </compilation>
+ <httpRuntime executionTimeout="300" requestValidationMode="2.0" />
+ <pages enableViewState="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
+ </system.web>
</configuration>
\ No newline at end of file
Modified: MonkeyWrench.Web.WebService/Makefile
===================================================================
@@ -20,6 +20,7 @@ REFERENCES = \
-r:Npgsql.dll \
-r:System.Data.dll \
-r:System.Web.dll \
+ -r:System.Runtime.Caching.dll \
-r:System.Web.Services.dll
SOURCES = \
Modified: MonkeyWrench.Web.WebService/MonkeyWrench.Web.WebService.csproj
===================================================================
@@ -45,11 +45,11 @@
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
- <Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Runtime.Caching" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonkeyWrench.Database\MonkeyWrench.Database.csproj">
@@ -115,6 +115,7 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -141,10 +142,9 @@
</FlavorProperties>
</VisualStudio>
<MonoDevelop>
- <Properties VerifyCodeBehindFields="true" VerifyCodeBehindEvents="true">
- <XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="true" />
+ <Properties VerifyCodeBehindFields="True" VerifyCodeBehindEvents="True">
+ <XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" />
</Properties>
</MonoDevelop>
</ProjectExtensions>
</Project>
-
Modified: MonkeyWrench.Web.WebService/Notifications.cs
===================================================================
@@ -15,6 +15,7 @@
using System.Data.Common;
using System.IO;
using System.Linq;
+using System.Runtime.Caching;
using System.Text;
using System.Threading;
using System.Web;
@@ -321,6 +322,7 @@ public class IrcNotification : NotificationBase
DBIrcIdentity identity;
string [] channels;
bool enabled = true;
+ ObjectCache cache = new MemoryCache ("IrcCache");
class IrcState
{
@@ -552,6 +554,10 @@ protected override void Notify (DBWork work, DBRevisionWork revision_work, List<
}
foreach (var nick in person.irc_nicknames.Split (',')) {
foreach (var channel in channels) {
+ var msg = nick + ": " + message;
+ if (cache [msg] != null)
+ continue;
+ cache.Add (msg, string.Empty, new DateTimeOffset (DateTime.UtcNow.AddHours (1), TimeSpan.Zero));
state.Client.SendMessage (SendType.Message, channel, nick + ": " + message, Priority.Critical);
}
}
Modified: MonkeyWrench.Web.WebService/web.config
===================================================================
@@ -1,10 +1,19 @@
<?xml version="1.0"?>
<configuration>
- <configSections/>
+ <configSections />
<system.web>
- <customErrors mode="Off"/>
- <compilation debug="true" targetFramework="4.0"/>
- <httpRuntime executionTimeout="300" maxRequestLength="2097151"/>
- <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
+ <customErrors mode="Off" />
+ <compilation debug="true" targetFramework="4.0">
+ <assemblies>
+ <add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <add assembly="System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ </assemblies>
+ </compilation>
+ <httpRuntime executionTimeout="300" maxRequestLength="2097151" />
+ <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
</configuration>
\ No newline at end of file
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches