refactor: fix some of phpstan's ignored errors
This commit is contained in:
parent
0de9c1ad23
commit
4c1a3e5015
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -20,6 +21,13 @@ use ViewThemes\Theme;
|
|||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,7 @@ use App\Models\EpisodeModel;
|
|||
use App\Models\PodcastModel;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
@ -27,6 +28,13 @@ use Psr\Log\LoggerInterface;
|
|||
|
||||
class EpisodeAudioController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all
|
||||
* other controllers that extend Analytics.
|
||||
|
|
|
@ -166,16 +166,24 @@ class EpisodeCommentController extends BaseController
|
|||
|
||||
public function attemptLike(): RedirectResponse
|
||||
{
|
||||
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
model(LikeModel::class)
|
||||
->toggleLike(interact_as_actor(), $this->comment);
|
||||
->toggleLike($interactAsActor, $this->comment);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function attemptReply(): RedirectResponse
|
||||
{
|
||||
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
model(LikeModel::class)
|
||||
->toggleLike(interact_as_actor(), $this->comment);
|
||||
->toggleLike($interactAsActor, $this->comment);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
|
|
@ -10,10 +10,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Entities\Podcast;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\PodcastModel;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Exception;
|
||||
use Modules\PremiumPodcasts\Entities\Subscription;
|
||||
|
@ -22,13 +24,20 @@ use Opawg\UserAgentsPhp\UserAgentsRSS;
|
|||
|
||||
class FeedController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
public function index(string $podcastHandle): ResponseInterface
|
||||
{
|
||||
helper(['rss', 'premium_podcasts', 'misc']);
|
||||
|
||||
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
||||
->first();
|
||||
if (! $podcast) {
|
||||
if (! $podcast instanceof Podcast) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@ class PageController extends BaseController
|
|||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
($page = (new PageModel())->where('slug', $params[0])->first()) === null
|
||||
) {
|
||||
$page = (new PageModel())->where('slug', $params[0])->first();
|
||||
if (! $page instanceof Page) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddCategories extends Migration
|
||||
class AddCategories extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddLanguages extends Migration
|
||||
class AddLanguages extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPodcasts extends Migration
|
||||
class AddPodcasts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddEpisodes extends Migration
|
||||
class AddEpisodes extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPlatforms extends Migration
|
||||
class AddPlatforms extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPodcastsPlatforms extends Migration
|
||||
class AddPodcastsPlatforms extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddEpisodeComments extends Migration
|
||||
class AddEpisodeComments extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddLikes extends Migration
|
||||
class AddLikes extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPages extends Migration
|
||||
class AddPages extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPodcastsCategories extends Migration
|
||||
class AddPodcastsCategories extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddClips extends Migration
|
||||
class AddClips extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPersons extends Migration
|
||||
class AddPersons extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddPodcastsPersons extends Migration
|
||||
class AddPodcastsPersons extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddEpisodesPersons extends Migration
|
||||
class AddEpisodesPersons extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddCreditsView extends Migration
|
||||
class AddCreditsView extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddEpisodeIdToPosts extends Migration
|
||||
class AddEpisodeIdToPosts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddCreatedByToPosts extends Migration
|
||||
class AddCreatedByToPosts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Class AddCreatedByToPosts Adds created_by field to posts table in database
|
||||
*
|
||||
* @copyright 2020 Ad Aures
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\BaseConnection;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class BaseMigration extends Migration
|
||||
{
|
||||
/**
|
||||
* Database Connection instance
|
||||
*
|
||||
* @var BaseConnection
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
}
|
|
@ -12,9 +12,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use App\Entities\Episode;
|
||||
use App\Entities\Podcast;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\PodcastModel;
|
||||
use CodeIgniter\Database\Seeder;
|
||||
use Exception;
|
||||
use GeoIp2\Database\Reader;
|
||||
|
||||
use GeoIp2\Exception\AddressNotFoundException;
|
||||
|
@ -41,162 +44,166 @@ class FakePodcastsAnalyticsSeeder extends Seeder
|
|||
|
||||
$podcast = (new PodcastModel())->first();
|
||||
|
||||
if ($podcast !== null) {
|
||||
$firstEpisode = (new EpisodeModel())
|
||||
->selectMin('published_at')
|
||||
->first();
|
||||
if (! $podcast instanceof Podcast) {
|
||||
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
|
||||
}
|
||||
|
||||
for (
|
||||
$date = strtotime((string) $firstEpisode->published_at);
|
||||
$date < strtotime('now');
|
||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||
) {
|
||||
$analyticsPodcasts = [];
|
||||
$analyticsPodcastsByHour = [];
|
||||
$analyticsPodcastsByCountry = [];
|
||||
$analyticsPodcastsByEpisode = [];
|
||||
$analyticsPodcastsByPlayer = [];
|
||||
$analyticsPodcastsByRegion = [];
|
||||
$firstEpisode = (new EpisodeModel())
|
||||
->selectMin('published_at')
|
||||
->first();
|
||||
|
||||
$episodes = (new EpisodeModel())
|
||||
->where('podcast_id', $podcast->id)
|
||||
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||
->findAll();
|
||||
foreach ($episodes as $episode) {
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||
$probability1 = floor(exp(3 - $age / 40)) + 1;
|
||||
if (! $firstEpisode instanceof Episode) {
|
||||
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
|
||||
}
|
||||
|
||||
for (
|
||||
$lineNumber = 0;
|
||||
$lineNumber < rand(1, (int) $probability1);
|
||||
++$lineNumber
|
||||
) {
|
||||
$probability2 = floor(exp(6 - $age / 20)) + 10;
|
||||
for (
|
||||
$date = strtotime((string) $firstEpisode->published_at);
|
||||
$date < strtotime('now');
|
||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||
) {
|
||||
$analyticsPodcasts = [];
|
||||
$analyticsPodcastsByHour = [];
|
||||
$analyticsPodcastsByCountry = [];
|
||||
$analyticsPodcastsByEpisode = [];
|
||||
$analyticsPodcastsByPlayer = [];
|
||||
$analyticsPodcastsByRegion = [];
|
||||
|
||||
$player =
|
||||
$jsonUserAgents[
|
||||
rand(1, count($jsonUserAgents) - 1)
|
||||
];
|
||||
$service =
|
||||
$jsonRSSUserAgents[
|
||||
rand(1, count($jsonRSSUserAgents) - 1)
|
||||
]['slug'];
|
||||
$app = isset($player['app']) ? $player['app'] : '';
|
||||
$device = isset($player['device'])
|
||||
? $player['device']
|
||||
: '';
|
||||
$os = isset($player['os']) ? $player['os'] : '';
|
||||
$isBot = isset($player['bot']) ? $player['bot'] : 0;
|
||||
$episodes = (new EpisodeModel())
|
||||
->where('podcast_id', $podcast->id)
|
||||
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||
->findAll();
|
||||
foreach ($episodes as $episode) {
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||
$probability1 = floor(exp(3 - $age / 40)) + 1;
|
||||
|
||||
$fakeIp =
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255);
|
||||
for (
|
||||
$lineNumber = 0;
|
||||
$lineNumber < rand(1, (int) $probability1);
|
||||
++$lineNumber
|
||||
) {
|
||||
$probability2 = floor(exp(6 - $age / 20)) + 10;
|
||||
|
||||
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
|
||||
|
||||
$countryCode = 'N/A';
|
||||
$regionCode = 'N/A';
|
||||
$latitude = null;
|
||||
$longitude = null;
|
||||
try {
|
||||
$city = $cityReader->city($fakeIp);
|
||||
|
||||
$countryCode = $city->country->isoCode === null
|
||||
? 'N/A'
|
||||
: $city->country->isoCode;
|
||||
|
||||
$regionCode = $city->subdivisions === []
|
||||
? 'N/A'
|
||||
: $city->subdivisions[0]->isoCode;
|
||||
$latitude = round((float) $city->location->latitude, 3);
|
||||
$longitude = round((float) $city->location->longitude, 3);
|
||||
} catch (AddressNotFoundException) {
|
||||
//Bad luck, bad IP, nothing to do.
|
||||
}
|
||||
|
||||
$hits = rand(0, (int) $probability2);
|
||||
|
||||
$analyticsPodcasts[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'duration' => rand(60, 3600),
|
||||
'bandwidth' => rand(1000000, 10000000),
|
||||
'hits' => $hits,
|
||||
'unique_listeners' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByHour[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'hour' => rand(0, 23),
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByCountry[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'country_code' => $countryCode,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByEpisode[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'episode_id' => $episode->id,
|
||||
'age' => $age,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByPlayer[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'service' => $service,
|
||||
'app' => $app,
|
||||
'device' => $device,
|
||||
'os' => $os,
|
||||
'is_bot' => $isBot,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByRegion[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'country_code' => $countryCode,
|
||||
'region_code' => $regionCode,
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
'hits' => $hits,
|
||||
$player =
|
||||
$jsonUserAgents[
|
||||
rand(1, count($jsonUserAgents) - 1)
|
||||
];
|
||||
$service =
|
||||
$jsonRSSUserAgents[
|
||||
rand(1, count($jsonRSSUserAgents) - 1)
|
||||
]['slug'];
|
||||
$app = isset($player['app']) ? $player['app'] : '';
|
||||
$device = isset($player['device'])
|
||||
? $player['device']
|
||||
: '';
|
||||
$os = isset($player['os']) ? $player['os'] : '';
|
||||
$isBot = isset($player['bot']) ? $player['bot'] : 0;
|
||||
|
||||
$fakeIp =
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255) .
|
||||
'.' .
|
||||
rand(0, 255);
|
||||
|
||||
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
|
||||
|
||||
$countryCode = 'N/A';
|
||||
$regionCode = 'N/A';
|
||||
$latitude = null;
|
||||
$longitude = null;
|
||||
try {
|
||||
$city = $cityReader->city($fakeIp);
|
||||
|
||||
$countryCode = $city->country->isoCode === null
|
||||
? 'N/A'
|
||||
: $city->country->isoCode;
|
||||
|
||||
$regionCode = $city->subdivisions === []
|
||||
? 'N/A'
|
||||
: $city->subdivisions[0]->isoCode;
|
||||
$latitude = round((float) $city->location->latitude, 3);
|
||||
$longitude = round((float) $city->location->longitude, 3);
|
||||
} catch (AddressNotFoundException) {
|
||||
//Bad luck, bad IP, nothing to do.
|
||||
}
|
||||
}
|
||||
|
||||
$this->db
|
||||
->table('analytics_podcasts')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcasts);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_hour')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByHour);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_country')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByCountry);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_episode')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByEpisode);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_player')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByPlayer);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_region')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByRegion);
|
||||
$hits = rand(0, (int) $probability2);
|
||||
|
||||
$analyticsPodcasts[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'duration' => rand(60, 3600),
|
||||
'bandwidth' => rand(1000000, 10000000),
|
||||
'hits' => $hits,
|
||||
'unique_listeners' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByHour[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'hour' => rand(0, 23),
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByCountry[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'country_code' => $countryCode,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByEpisode[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'episode_id' => $episode->id,
|
||||
'age' => $age,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByPlayer[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'service' => $service,
|
||||
'app' => $app,
|
||||
'device' => $device,
|
||||
'os' => $os,
|
||||
'is_bot' => $isBot,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$analyticsPodcastsByRegion[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'country_code' => $countryCode,
|
||||
'region_code' => $regionCode,
|
||||
'latitude' => $latitude,
|
||||
'longitude' => $longitude,
|
||||
'hits' => $hits,
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n";
|
||||
|
||||
$this->db
|
||||
->table('analytics_podcasts')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcasts);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_hour')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByHour);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_country')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByCountry);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_episode')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByEpisode);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_player')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByPlayer);
|
||||
$this->db
|
||||
->table('analytics_podcasts_by_region')
|
||||
->ignore(true)
|
||||
->insertBatch($analyticsPodcastsByRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Seeds;
|
||||
|
||||
use App\Entities\Episode;
|
||||
use App\Entities\Podcast;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\PodcastModel;
|
||||
|
||||
use CodeIgniter\Database\Seeder;
|
||||
use Exception;
|
||||
|
||||
class FakeWebsiteAnalyticsSeeder extends Seeder
|
||||
{
|
||||
|
@ -183,86 +186,90 @@ class FakeWebsiteAnalyticsSeeder extends Seeder
|
|||
{
|
||||
$podcast = (new PodcastModel())->first();
|
||||
|
||||
if ($podcast) {
|
||||
$firstEpisode = (new EpisodeModel())
|
||||
->selectMin('published_at')
|
||||
->first();
|
||||
if (! $podcast instanceof Podcast) {
|
||||
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
|
||||
}
|
||||
|
||||
for (
|
||||
$date = strtotime((string) $firstEpisode->published_at);
|
||||
$date < strtotime('now');
|
||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||
) {
|
||||
$websiteByBrowser = [];
|
||||
$websiteByEntryPage = [];
|
||||
$websiteByReferer = [];
|
||||
$firstEpisode = (new EpisodeModel())
|
||||
->selectMin('published_at')
|
||||
->first();
|
||||
|
||||
$episodes = (new EpisodeModel())
|
||||
->where('podcast_id', $podcast->id)
|
||||
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||
->findAll();
|
||||
foreach ($episodes as $episode) {
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
|
||||
if (! $firstEpisode instanceof Episode) {
|
||||
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
|
||||
}
|
||||
|
||||
for (
|
||||
$lineNumber = 0;
|
||||
$lineNumber < rand(1, $probability1);
|
||||
++$lineNumber
|
||||
) {
|
||||
$probability2 = (int) floor(exp(6 - $age / 20)) + 10;
|
||||
for (
|
||||
$date = strtotime((string) $firstEpisode->published_at);
|
||||
$date < strtotime('now');
|
||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||
) {
|
||||
$websiteByBrowser = [];
|
||||
$websiteByEntryPage = [];
|
||||
$websiteByReferer = [];
|
||||
|
||||
$domain =
|
||||
$this->domains[rand(0, count($this->domains) - 1)];
|
||||
$keyword =
|
||||
$this->keywords[
|
||||
rand(0, count($this->keywords) - 1)
|
||||
];
|
||||
$browser =
|
||||
$this->browsers[
|
||||
rand(0, count($this->browsers) - 1)
|
||||
];
|
||||
$episodes = (new EpisodeModel())
|
||||
->where('podcast_id', $podcast->id)
|
||||
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||
->findAll();
|
||||
foreach ($episodes as $episode) {
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
|
||||
|
||||
$hits = rand(0, $probability2);
|
||||
for (
|
||||
$lineNumber = 0;
|
||||
$lineNumber < rand(1, $probability1);
|
||||
++$lineNumber
|
||||
) {
|
||||
$probability2 = (int) floor(exp(6 - $age / 20)) + 10;
|
||||
|
||||
$websiteByBrowser[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'browser' => $browser,
|
||||
'hits' => $hits,
|
||||
$domain =
|
||||
$this->domains[rand(0, count($this->domains) - 1)];
|
||||
$keyword =
|
||||
$this->keywords[
|
||||
rand(0, count($this->keywords) - 1)
|
||||
];
|
||||
$websiteByEntryPage[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'entry_page_url' => $episode->link,
|
||||
'hits' => $hits,
|
||||
$browser =
|
||||
$this->browsers[
|
||||
rand(0, count($this->browsers) - 1)
|
||||
];
|
||||
$websiteByReferer[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'referer_url' => 'http://' . $domain . '/?q=' . $keyword,
|
||||
'domain' => $domain,
|
||||
'keywords' => $keyword,
|
||||
'hits' => $hits,
|
||||
];
|
||||
}
|
||||
|
||||
$hits = rand(0, $probability2);
|
||||
|
||||
$websiteByBrowser[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'browser' => $browser,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$websiteByEntryPage[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'entry_page_url' => $episode->link,
|
||||
'hits' => $hits,
|
||||
];
|
||||
$websiteByReferer[] = [
|
||||
'podcast_id' => $podcast->id,
|
||||
'date' => date('Y-m-d', $date),
|
||||
'referer_url' => 'http://' . $domain . '/?q=' . $keyword,
|
||||
'domain' => $domain,
|
||||
'keywords' => $keyword,
|
||||
'hits' => $hits,
|
||||
];
|
||||
}
|
||||
|
||||
$this->db
|
||||
->table('analytics_website_by_browser')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByBrowser);
|
||||
$this->db
|
||||
->table('analytics_website_by_entry_page')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByEntryPage);
|
||||
$this->db
|
||||
->table('analytics_website_by_referer')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByReferer);
|
||||
}
|
||||
} else {
|
||||
echo "COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n";
|
||||
|
||||
$this->db
|
||||
->table('analytics_website_by_browser')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByBrowser);
|
||||
$this->db
|
||||
->table('analytics_website_by_entry_page')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByEntryPage);
|
||||
$this->db
|
||||
->table('analytics_website_by_referer')
|
||||
->ignore(true)
|
||||
->insertBatch($websiteByReferer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ class BaseClip extends Entity
|
|||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
/** @var ?User */
|
||||
return (new UserModel())->find($this->created_by);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ class Credit extends Entity
|
|||
return '';
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
return lang("PersonsTaxonomy.persons.{$this->person_group}.label");
|
||||
}
|
||||
|
||||
|
@ -111,6 +112,7 @@ class Credit extends Entity
|
|||
return '';
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
return lang("PersonsTaxonomy.persons.{$this->person_group}.roles.{$this->person_role}.label");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ use Modules\Media\Entities\Image;
|
|||
use Modules\Media\Entities\Transcript;
|
||||
use Modules\Media\Models\MediaModel;
|
||||
use RuntimeException;
|
||||
use SimpleXMLElement;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
|
@ -619,13 +620,19 @@ class Episode extends Entity
|
|||
}
|
||||
|
||||
helper('rss');
|
||||
$customRssArray = rss_to_array(
|
||||
simplexml_load_string(
|
||||
'<?xml version="1.0" encoding="utf-8"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><item>' .
|
||||
$customRssString .
|
||||
'</item></channel></rss>',
|
||||
),
|
||||
)['elements'][0]['elements'][0];
|
||||
|
||||
$customXML = simplexml_load_string(
|
||||
'<?xml version="1.0" encoding="utf-8"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><item>' .
|
||||
$customRssString .
|
||||
'</item></channel></rss>',
|
||||
);
|
||||
|
||||
if (! $customXML instanceof SimpleXMLElement) {
|
||||
// TODO: Failed to parse custom xml, should return error?
|
||||
return $this;
|
||||
}
|
||||
|
||||
$customRssArray = rss_to_array($customXML)['elements'][0]['elements'][0];
|
||||
|
||||
if (array_key_exists('elements', $customRssArray)) {
|
||||
$this->attributes['custom_rss'] = json_encode($customRssArray['elements']);
|
||||
|
|
|
@ -21,6 +21,7 @@ use CodeIgniter\Files\File;
|
|||
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use CodeIgniter\Shield\Entities\User;
|
||||
use Exception;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\Autolink\AutolinkExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
|
@ -260,7 +261,13 @@ class Podcast extends Entity
|
|||
public function getCover(): Image
|
||||
{
|
||||
if (! $this->cover instanceof Image) {
|
||||
$this->cover = (new MediaModel('image'))->getMediaById($this->cover_id);
|
||||
$cover = (new MediaModel('image'))->getMediaById($this->cover_id);
|
||||
|
||||
if (! $cover instanceof Image) {
|
||||
throw new Exception('Could not retrieve podcast cover.');
|
||||
}
|
||||
|
||||
$this->cover = $cover;
|
||||
}
|
||||
|
||||
return $this->cover;
|
||||
|
|
|
@ -40,7 +40,9 @@ if (! function_exists('current_domain')) {
|
|||
*/
|
||||
function current_domain(): string
|
||||
{
|
||||
/** @var URI $uri */
|
||||
$uri = current_url(true);
|
||||
|
||||
return $uri->getHost() . ($uri->getPort() ? ':' . $uri->getPort() : '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\Actor;
|
||||
use App\Entities\Episode;
|
||||
use App\Entities\EpisodeComment;
|
||||
use App\Libraries\CommentObject;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
|
@ -297,7 +299,15 @@ class EpisodeCommentModel extends UuidModel
|
|||
$episode = model(EpisodeModel::class, false)
|
||||
->find((int) $data['data']['episode_id']);
|
||||
|
||||
$data['data']['uri'] = url_to('episode-comment', esc($actor->username), $episode->slug, $uuid4->toString());
|
||||
if (! $episode instanceof Episode) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (! $actor instanceof Actor) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['data']['uri'] = url_to('episode-comment', $actor->username, $episode->slug, $uuid4->toString());
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
|
@ -15,6 +15,7 @@ use App\Entities\Like;
|
|||
use Michalsn\Uuid\UuidModel;
|
||||
use Modules\Fediverse\Activities\LikeActivity;
|
||||
use Modules\Fediverse\Activities\UndoActivity;
|
||||
use Modules\Fediverse\Entities\Activity;
|
||||
use Modules\Fediverse\Entities\Actor;
|
||||
use Modules\Fediverse\Models\ActivityModel;
|
||||
|
||||
|
@ -113,6 +114,11 @@ class LikeModel extends UuidModel
|
|||
])
|
||||
->first();
|
||||
|
||||
if (! $activity instanceof Activity) {
|
||||
// no like activity found, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
$likeActivity = new LikeActivity();
|
||||
$likeActivity
|
||||
->set('id', url_to('activity', esc($actor->username), $activity->id))
|
||||
|
|
|
@ -439,12 +439,14 @@ class PodcastModel extends Model
|
|||
if ($podcast instanceof Podcast) {
|
||||
$podcastActor = (new ActorModel())->find($podcast->actor_id);
|
||||
|
||||
if ($podcastActor) {
|
||||
$podcastActor->avatar_image_url = $podcast->cover->federation_url;
|
||||
$podcastActor->avatar_image_mimetype = $podcast->cover->federation_mimetype;
|
||||
|
||||
(new ActorModel())->update($podcast->actor_id, $podcastActor);
|
||||
if (! $podcastActor instanceof Actor) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$podcastActor->avatar_image_url = $podcast->cover->federation_url;
|
||||
$podcastActor->avatar_image_mimetype = $podcast->cover->federation_mimetype;
|
||||
|
||||
(new ActorModel())->update($podcast->actor_id, $podcastActor);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcasts extends Migration
|
||||
class AddAnalyticsPodcasts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsByEpisode extends Migration
|
||||
class AddAnalyticsPodcastsByEpisode extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsByHour extends Migration
|
||||
class AddAnalyticsPodcastsByHour extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsByPlayer extends Migration
|
||||
class AddAnalyticsPodcastsByPlayer extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsByCountry extends Migration
|
||||
class AddAnalyticsPodcastsByCountry extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsByRegion extends Migration
|
||||
class AddAnalyticsPodcastsByRegion extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsWebsiteByBrowser extends Migration
|
||||
class AddAnalyticsWebsiteByBrowser extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsWebsiteByReferer extends Migration
|
||||
class AddAnalyticsWebsiteByReferer extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsWebsiteByEntryPage extends Migration
|
||||
class AddAnalyticsWebsiteByEntryPage extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsUnknownUseragents extends Migration
|
||||
class AddAnalyticsUnknownUseragents extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsBySubscription extends Migration
|
||||
class AddAnalyticsPodcastsBySubscription extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsPodcastsProcedure extends Migration
|
||||
class AddAnalyticsPodcastsProcedure extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsUnknownUseragentsProcedure extends Migration
|
||||
class AddAnalyticsUnknownUseragentsProcedure extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Analytics\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddAnalyticsWebsiteProcedure extends Migration
|
||||
class AddAnalyticsWebsiteProcedure extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -4,9 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddIsOwnerToUsers extends Migration
|
||||
class AddIsOwnerToUsers extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -68,15 +68,15 @@ if (! function_exists('interact_as_actor')) {
|
|||
/**
|
||||
* Get the actor the user is currently interacting as
|
||||
*/
|
||||
function interact_as_actor(): Actor | false
|
||||
function interact_as_actor(): ?Actor
|
||||
{
|
||||
if (! auth()->loggedIn()) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$session = session();
|
||||
if (! $session->has('interact_as_actor_id')) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return model(ActorModel::class, false)->getActorById($session->get('interact_as_actor_id'));
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Modules\Fediverse\Controllers;
|
|||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
@ -23,6 +24,13 @@ use Modules\Fediverse\Objects\OrderedCollectionPage;
|
|||
|
||||
class PostController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
|
|
|
@ -47,8 +47,8 @@ abstract class AbstractObject
|
|||
});
|
||||
}
|
||||
|
||||
public function toJSON(): string | bool
|
||||
public function toJSON(): string
|
||||
{
|
||||
return json_encode($this->toArray(), JSON_UNESCAPED_UNICODE);
|
||||
return (string) json_encode($this->toArray(), JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddActors extends Migration
|
||||
class AddActors extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddPosts extends Migration
|
||||
class AddPosts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddActivities extends Migration
|
||||
class AddActivities extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddFavourites extends Migration
|
||||
class AddFavourites extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddFollowers extends Migration
|
||||
class AddFollowers extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddPreviewCards extends Migration
|
||||
class AddPreviewCards extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddPostsPreviewCards extends Migration
|
||||
class AddPostsPreviewCards extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Fediverse\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddBlockedDomains extends Migration
|
||||
class AddBlockedDomains extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddNotifications extends Migration
|
||||
class AddNotifications extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Media\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddMedia extends Migration
|
||||
class AddMedia extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Media\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class RenameMediafileKey extends Migration
|
||||
class RenameMediafileKey extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\PremiumPodcasts\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddSubscriptions extends Migration
|
||||
class AddSubscriptions extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WebSub\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddIsPublishedOnHubsToPodcasts extends Migration
|
||||
class AddIsPublishedOnHubsToPodcasts extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WebSub\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
use App\Database\Migrations\BaseMigration;
|
||||
|
||||
class AddIsPublishedOnHubsToEpisodes extends Migration
|
||||
class AddIsPublishedOnHubsToEpisodes extends BaseMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
|
|
@ -27,7 +27,4 @@ parameters:
|
|||
- ENVIRONMENT
|
||||
- SODIUM_LIBRARY_VERSION
|
||||
ignoreErrors:
|
||||
- '#Cannot access property [\$a-z_]+ on ((array\|)?object)#'
|
||||
- '#^Call to an undefined method CodeIgniter\\Database\\ConnectionInterface#'
|
||||
- '#^Access to an undefined property Modules\\Media\\Entities\\Image#'
|
||||
- '#^Call to an undefined method CodeIgniter\\HTTP\\RequestInterface#'
|
||||
|
|
|
@ -36,6 +36,11 @@ class ExampleDatabaseTest extends CIUnitTestCase
|
|||
$this->setPrivateProperty($model, 'tempUseSoftDeletes', true);
|
||||
|
||||
$object = $model->first();
|
||||
|
||||
if (! is_object($object)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$model->delete($object->id);
|
||||
|
||||
// The model should no longer find it
|
||||
|
|
Loading…
Reference in New Issue