<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=OnSpam</id>
	<title>OnSpam - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=OnSpam"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=OnSpam&amp;action=history"/>
	<updated>2026-08-22T03:32:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=OnSpam&amp;diff=27218&amp;oldid=prev</id>
		<title>Cmatte: Fix deprecation warning in scrip</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=OnSpam&amp;diff=27218&amp;oldid=prev"/>
		<updated>2025-02-27T16:41:09Z</updated>

		<summary type="html">&lt;p&gt;Fix deprecation warning in scrip&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:41, 27 February 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l39&quot;&gt;Line 39:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;my $tickets_today = RT::Tickets-&amp;gt;new($RT::SystemUser);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;my $tickets_today = RT::Tickets-&amp;gt;new($RT::SystemUser);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tickets_today-&amp;gt;LimitCreated(OPERATOR =&amp;gt; &amp;#039;&amp;gt;=&amp;#039;, VALUE =&amp;gt; $today-&amp;gt;ISO);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tickets_today-&amp;gt;LimitCreated(OPERATOR =&amp;gt; &amp;#039;&amp;gt;=&amp;#039;, VALUE =&amp;gt; $today-&amp;gt;ISO);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tickets_today-&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Limit&lt;/del&gt;(FIELD =&amp;gt; &#039;Creator&#039;, VALUE =&amp;gt; $user);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;$tickets_today-&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;LimitField&lt;/ins&gt;(FIELD =&amp;gt; &#039;Creator&#039;, VALUE =&amp;gt; $user);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if ($tickets_today-&amp;gt;Count &amp;gt; $limit) {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;if ($tickets_today-&amp;gt;Count &amp;gt; $limit) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-27209:rev-27218:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Cmatte</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=OnSpam&amp;diff=27209&amp;oldid=prev</id>
		<title>Cmatte: Create page</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=OnSpam&amp;diff=27209&amp;oldid=prev"/>
		<updated>2024-09-20T16:09:04Z</updated>

		<summary type="html">&lt;p&gt;Create page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Author:&amp;#039;&amp;#039;&amp;#039; Célestin Matte, while working for [https://spi-inc.org SPI]&lt;br /&gt;
&lt;br /&gt;
The instance I’m managing has a policy of allowing anyone to create tickets. As a result, it is occasionally struck with email loops, when poorly-configured systems auto-respond to the ticket creation confirmation email.&lt;br /&gt;
&lt;br /&gt;
In order to stop these email loops, I created this scrip that blocks users that create more than a certain number of tickets in a day.&lt;br /&gt;
&lt;br /&gt;
This will add a comment in the last ticket indicating the block. Blocked users will be informed through “permission denied” emails.&lt;br /&gt;
&lt;br /&gt;
Note: Technically, this will not stop the email loop between RT and users (you can’t prevent emails from being sent from scrips), but it will stop new tickets creation. I use this method because I’m not hosting this instance and have therefore no access to server-side settings, which would be necessary to completely break the loop.&lt;br /&gt;
&lt;br /&gt;
This can also be used to block spammers.&lt;br /&gt;
&lt;br /&gt;
== Scrip ==&lt;br /&gt;
&lt;br /&gt;
* Description: Ticket creation rate limiting&lt;br /&gt;
* Condition: On Create&lt;br /&gt;
* Action: User Defined&lt;br /&gt;
* Template: Blank&lt;br /&gt;
&lt;br /&gt;
Custom action preparation code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
my $user = $self-&amp;gt;TransactionObj-&amp;gt;Creator;&lt;br /&gt;
my $limit = 30; # Maximum tickets per day&lt;br /&gt;
&lt;br /&gt;
# A user that won&amp;#039;t be affected by the rate limitation&lt;br /&gt;
my $excluded_user = &amp;#039;someuse@domain.com&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
if ($self-&amp;gt;TicketObj-&amp;gt;RequestorAddresses eq $excluded_user) {&lt;br /&gt;
    return 0; # Allow the ticket creation without limits for excluded user&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get today&amp;#039;s date in a format RT can use&lt;br /&gt;
my $today = RT::Date-&amp;gt;new($RT::SystemUser);&lt;br /&gt;
$today-&amp;gt;Set(Format =&amp;gt; &amp;#039;unknown&amp;#039;, Value =&amp;gt; &amp;#039;today&amp;#039;);&lt;br /&gt;
$today-&amp;gt;SetToMidnight();&lt;br /&gt;
&lt;br /&gt;
# Search for tickets created by the user today&lt;br /&gt;
my $tickets_today = RT::Tickets-&amp;gt;new($RT::SystemUser);&lt;br /&gt;
$tickets_today-&amp;gt;LimitCreated(OPERATOR =&amp;gt; &amp;#039;&amp;gt;=&amp;#039;, VALUE =&amp;gt; $today-&amp;gt;ISO);&lt;br /&gt;
$tickets_today-&amp;gt;Limit(FIELD =&amp;gt; &amp;#039;Creator&amp;#039;, VALUE =&amp;gt; $user);&lt;br /&gt;
&lt;br /&gt;
if ($tickets_today-&amp;gt;Count &amp;gt; $limit) {&lt;br /&gt;
    $self-&amp;gt;TicketObj-&amp;gt;Comment(Content =&amp;gt; &amp;quot;Rate limit reached for user&amp;quot; );&lt;br /&gt;
    return 1; # Prevent ticket creation&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return 0; # Allow ticket creation to proceed&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Custom action commit code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Delete the ticket&lt;br /&gt;
# my $ticket = $self-&amp;gt;TicketObj;&lt;br /&gt;
#$ticket-&amp;gt;Delete();&lt;br /&gt;
&lt;br /&gt;
my $user = $self-&amp;gt;TicketObj-&amp;gt;CreatorObj;&lt;br /&gt;
&lt;br /&gt;
my $res = $user-&amp;gt;SetEmailAddress(&amp;quot;&amp;quot;);&lt;br /&gt;
my $res2 = $user-&amp;gt;SetDisabled(1);&lt;br /&gt;
&lt;br /&gt;
$self-&amp;gt;TicketObj-&amp;gt;Comment(Content =&amp;gt; &amp;quot;Email address change result: $res\nUser disabling result: $res2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
return 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cmatte</name></author>
	</entry>
</feed>