aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-comments
diff options
context:
space:
mode:
Diffstat (limited to 'bin/send-comments')
-rwxr-xr-xbin/send-comments43
1 files changed, 24 insertions, 19 deletions
diff --git a/bin/send-comments b/bin/send-comments
index fbbd57891..7363d7a0d 100755
--- a/bin/send-comments
+++ b/bin/send-comments
@@ -20,15 +20,12 @@ BEGIN {
require "$d/../setenv.pl";
}
-use Digest::MD5;
-use Encode;
use CronFns;
-use FixMyStreet::App;
-
-use Utils;
-use mySociety::Config;
-
+use DateTime;
+use FixMyStreet;
+use FixMyStreet::Cobrand;
+use FixMyStreet::DB;
use Open311;
# send_method config values found in by-area config data, for selecting to appropriate method
@@ -36,25 +33,33 @@ use constant SEND_METHOD_EMAIL => 'email';
use constant SEND_METHOD_OPEN311 => 'Open311';
use constant COUNCIL_ID_OXFORDSHIRE => 2237;
+use constant COUNCIL_ID_BROMLEY => 2482;
+use constant COUNCIL_ID_LEWISHAM => 2492;
# Set up site, language etc.
my ($verbose, $nomail) = CronFns::options();
-my $base_url = mySociety::Config::get('BASE_URL');
-my $site = CronFns::site($base_url);
+my $base_url = FixMyStreet->config('BASE_URL');
+my $site = '';
+$site = 'fixmystreet.com' if $base_url eq "https://www.fixmystreet.com";
-my $bodies = FixMyStreet::App->model('DB::Body')->search( {
+my $bodies = FixMyStreet::DB->resultset('Body')->search( {
send_method => SEND_METHOD_OPEN311,
send_comments => 1,
} );
while ( my $body = $bodies->next ) {
- # Oxfordshire (OCC) is special:
- # we do *receive* service_request_updates (aka comments) for OCC, but we never *send* them, so skip this pass
- next if $body->areas->{+COUNCIL_ID_OXFORDSHIRE};
+ # XXX Cobrand specific
+ if ($site eq 'fixmystreet.com') {
+ # Oxfordshire (OCC) is special:
+ # we do *receive* service_request_updates (aka comments) for OCC, but we never *send* them, so skip this pass
+ next if $body->areas->{+COUNCIL_ID_OXFORDSHIRE};
+ # Lewisham does not yet accept updates
+ next if $body->areas->{+COUNCIL_ID_LEWISHAM};
+ }
my $use_extended = 0;
- my $comments = FixMyStreet::App->model('DB::Comment')->search( {
+ my $comments = FixMyStreet::DB->resultset('Comment')->search( {
'me.whensent' => undef,
'me.external_id' => undef,
'me.state' => 'confirmed',
@@ -69,7 +74,7 @@ while ( my $body = $bodies->next ) {
}
);
- if ( $body->areas->{2482} ) {
+ if ( $site eq 'fixmystreet.com' && $body->areas->{+COUNCIL_ID_BROMLEY} ) {
$use_extended = 1;
}
@@ -87,7 +92,7 @@ while ( my $body = $bodies->next ) {
my $o = Open311->new( %open311_conf );
- if ( $body->areas->{2482} ) {
+ if ( $site eq 'fixmystreet.com' && $body->areas->{+COUNCIL_ID_BROMLEY} ) {
my $endpoints = $o->endpoints;
$endpoints->{update} = 'update.xml';
$endpoints->{service_request_updates} = 'update.xml';
@@ -110,10 +115,10 @@ while ( my $body = $bodies->next ) {
}
if ( $comment->send_fail_count ) {
- next if bromley_retry_timeout( $comment );
+ next if retry_timeout( $comment );
}
- if ( $body->areas->{2482} ) {
+ if ( $site eq 'fixmystreet.com' && $body->areas->{+COUNCIL_ID_BROMLEY} ) {
my $extra = $comment->extra;
if ( !$extra ) {
$extra = {};
@@ -142,7 +147,7 @@ while ( my $body = $bodies->next ) {
}
}
-sub bromley_retry_timeout {
+sub retry_timeout {
my $row = shift;
my $tz = FixMyStreet->local_time_zone;