deal with expiring peertube View activities which only exist for 2 minutes

This commit is contained in:
Mike Macgirvin 2023-10-25 21:02:15 +11:00
parent 262777b68d
commit a655d11423
2 changed files with 5 additions and 3 deletions

View file

@ -2955,6 +2955,7 @@ class Activity
} elseif ($act->objprop('updated')) {
$item['edited'] = datetime_convert('UTC', 'UTC', $act->obj['updated']);
}
if (array_key_exists('expires', $act->data) && $act->data['expires']) {
$item['expires'] = datetime_convert('UTC', 'UTC', $act->data['expires']);
} elseif ($act->objprop('expires')) {
@ -2966,8 +2967,9 @@ class Activity
} elseif ($act->objprop('expiresAt')) {
$item['expires'] = datetime_convert('UTC', 'UTC', $act->obj['expiresAt']);
}
if ($item['expires'] > NULL_DATE && $item['expires'] < datetime_convert()) {
// this will prevent peertube View activities which only exist for 2 minutes, but are like
// scrobblers and seem to only put noise into your stream and then vanish abruptly.
if ($item['expires'] > NULL_DATE && $item['expires'] < datetime_convert(datetime: 'now + 15 minutes')) {
// We shouldn't even be seeing this activity.
return false;
}

View file

@ -953,7 +953,7 @@ function encode_item($item,$mirror = false) {
$x['created'] = $item['created'];
$x['edited'] = $item['edited'];
// always send 0's over the wire
$x['expires'] = (($item['expires'] == '0001-01-01 00:00:00') ? '0000-00-00 00:00:00' : $item['expires']);
$x['expires'] = (($item['expires'] === '0001-01-01 00:00:00') ? '0000-00-00 00:00:00' : $item['expires']);
$x['commented'] = $item['commented'];
$x['mimetype'] = $item['mimetype'];
$x['title'] = $item['title'];