Skip to content

Commit

Permalink
new hold status and url checks #156
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Oct 28, 2021
1 parent 5322bc5 commit 7138490
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/1.2/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ function result_callback($msg, $queue) {
if (!(@count($data['networks']) == 1 && ($data['networks'][0] == 'ORG' || $data['networks'][0] == "BBFC"))) {
// we are submittingt to ISPs, not feedback to ORG or BBFC
if ($app['db.blacklist.load']->check($url['url'])) {
debug_log("{$url['url']} is blacklisted; not submitting");
debug_log("{$url['url']} cannot be submitted");
return $app->json(array('success' => false, 'message' => 'domain rejected'));
}
}
Expand Down Expand Up @@ -1695,6 +1695,8 @@ function result_callback($msg, $queue) {
$ids = array();
$queued = array();
$rejected = array();

$hold = $app['db.url.load']->has_hold_category($url['urlid']);
foreach($data['networks'] as $network_name) {
debug_log("Looking up: ". $network_name);
$age_limit = false;
Expand Down Expand Up @@ -1724,6 +1726,10 @@ function result_callback($msg, $queue) {
continue;
}

if ($hold) {
$queued[] = $network_name;
}

if ($app['db.ispreport.load']->can_report($url['urlid'], $network_name)) {

$mailname = "reply-" . strtolower(Middleware::generateSharedSecret(12));
Expand All @@ -1738,14 +1744,14 @@ function result_callback($msg, $queue) {
(@$data['send_updates'] ? 1 : 0),
$contact['id'],
(@$data['allow_publish'] ? 1: 0),
$age_limit ? 'pending' : 'sent',
$hold ? 'hold' : $age_limit ? 'pending' : 'sent',
@$data['category'],
(@$data['allow_contact'] ? 1: 0),
@$data['usertype'] ? $data['usertype'] : null
);
# send email here

if (($contact['verified'] || $network_name == 'ORG') && $network_name != 'BBFC' && $age_limit == false) {
if (($contact['verified'] || $network_name == 'ORG') && $network_name != 'BBFC' && $age_limit == false && $hold == false) {
sendISPReport(
$mailname,
$data['reporter']['name'],
Expand Down
15 changes: 15 additions & 0 deletions api/1.2/libs/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@ function load_categories_ns($urlID) {
return $out;
}

function has_hold_category($urlID) {
$result = $this->conn->query(
"select count(*) from url_categories
inner join categories on category_id = categories.id
where categories.hold = true and urlid = ?",
array($urlID),
PDO::FETCH_NUM
);
$row = $result->fetch();
if ($row[0] > 0) {
return true;
}
return false;
}

function updateLastPolled($urlid) {
$result = $this->conn->query("update urls set lastPolled=now() where urlID=?",
array($urlid));
Expand Down
2 changes: 2 additions & 0 deletions sql/pg.schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ CREATE TYPE public.enum_probe_status AS ENUM (
CREATE TYPE public.enum_report_status AS ENUM (
'new',
'pending',
'hold',
'sent',
'abuse',
'cancelled',
Expand Down Expand Up @@ -611,6 +612,7 @@ CREATE TABLE public.categories (
tree public.ltree,
name text,
name_fts tsvector,
hold bool default false,
namespace character varying(16),
created timestamp with time zone,
last_updated timestamp with time zone
Expand Down

0 comments on commit 7138490

Please sign in to comment.