From b3bbe99cc4f3871553bea1dca32ff73bdeeea724 Mon Sep 17 00:00:00 2001 From: Lukas Erlacher Date: Fri, 29 Aug 2025 11:23:36 +1000 Subject: [PATCH] Reactor/Linear: Limit Linear Expando Expanding ticket mentions can create a lot of spam. Introduce a user pref for the max number of ticket mentions to react to, so it can be limited. --- lib/Synergy/Reactor/Linear.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Synergy/Reactor/Linear.pm b/lib/Synergy/Reactor/Linear.pm index 5a4af16d..0ab139f1 100644 --- a/lib/Synergy/Reactor/Linear.pm +++ b/lib/Synergy/Reactor/Linear.pm @@ -202,6 +202,11 @@ listener issue_mention => async sub ($self, $event) { return unless @matches; + # if there's more than 3 issues to unroll that's probably spam + my $max_matches = + $self->get_user_preference($event->from_user, 'expando-limit'); + return unless @matches <= $max_matches; + # Do not warn about missing tokens in public about in-passing mentions my $user = $event->from_user; if ( $event->is_public @@ -1202,4 +1207,16 @@ __PACKAGE__->add_preference( validator => async sub ($self, $value, @) { return bool_from_text($value) }, ); +__PACKAGE__->add_preference( + name => 'expando-limit', + help => "Max number of Linear ticket mentions to expand in one post. Default is 999 i.e. never limit", + default => 999, + validator => async sub ($self, $value, @) { + unless ($value =~ /\A[0-9][0-9]+\z/ && $value < 1000) { + return (undef, "Your expando limit has to be a number between 0 and 999, inclusive."); + } + return $value; + } +); + 1;