mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-23 16:05:34 +00:00
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;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -20,6 +21,13 @@ use ViewThemes\Theme;
|
|||||||
*/
|
*/
|
||||||
abstract class BaseController extends Controller
|
abstract class BaseController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Instance of the main Request object.
|
||||||
|
*
|
||||||
|
* @var IncomingRequest
|
||||||
|
*/
|
||||||
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,7 @@ use App\Models\EpisodeModel;
|
|||||||
use App\Models\PodcastModel;
|
use App\Models\PodcastModel;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
use CodeIgniter\HTTP\RedirectResponse;
|
use CodeIgniter\HTTP\RedirectResponse;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
@ -27,6 +28,13 @@ use Psr\Log\LoggerInterface;
|
|||||||
|
|
||||||
class EpisodeAudioController extends Controller
|
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
|
* An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all
|
||||||
* other controllers that extend Analytics.
|
* other controllers that extend Analytics.
|
||||||
|
@ -166,16 +166,24 @@ class EpisodeCommentController extends BaseController
|
|||||||
|
|
||||||
public function attemptLike(): RedirectResponse
|
public function attemptLike(): RedirectResponse
|
||||||
{
|
{
|
||||||
|
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
model(LikeModel::class)
|
model(LikeModel::class)
|
||||||
->toggleLike(interact_as_actor(), $this->comment);
|
->toggleLike($interactAsActor, $this->comment);
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attemptReply(): RedirectResponse
|
public function attemptReply(): RedirectResponse
|
||||||
{
|
{
|
||||||
|
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
model(LikeModel::class)
|
model(LikeModel::class)
|
||||||
->toggleLike(interact_as_actor(), $this->comment);
|
->toggleLike($interactAsActor, $this->comment);
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
use App\Entities\Podcast;
|
||||||
use App\Models\EpisodeModel;
|
use App\Models\EpisodeModel;
|
||||||
use App\Models\PodcastModel;
|
use App\Models\PodcastModel;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Modules\PremiumPodcasts\Entities\Subscription;
|
use Modules\PremiumPodcasts\Entities\Subscription;
|
||||||
@ -22,13 +24,20 @@ use Opawg\UserAgentsPhp\UserAgentsRSS;
|
|||||||
|
|
||||||
class FeedController extends Controller
|
class FeedController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Instance of the main Request object.
|
||||||
|
*
|
||||||
|
* @var IncomingRequest
|
||||||
|
*/
|
||||||
|
protected $request;
|
||||||
|
|
||||||
public function index(string $podcastHandle): ResponseInterface
|
public function index(string $podcastHandle): ResponseInterface
|
||||||
{
|
{
|
||||||
helper(['rss', 'premium_podcasts', 'misc']);
|
helper(['rss', 'premium_podcasts', 'misc']);
|
||||||
|
|
||||||
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
||||||
->first();
|
->first();
|
||||||
if (! $podcast) {
|
if (! $podcast instanceof Podcast) {
|
||||||
throw PageNotFoundException::forPageNotFound();
|
throw PageNotFoundException::forPageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,9 +24,8 @@ class PageController extends BaseController
|
|||||||
throw PageNotFoundException::forPageNotFound();
|
throw PageNotFoundException::forPageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
$page = (new PageModel())->where('slug', $params[0])->first();
|
||||||
($page = (new PageModel())->where('slug', $params[0])->first()) === null
|
if (! $page instanceof Page) {
|
||||||
) {
|
|
||||||
throw PageNotFoundException::forPageNotFound();
|
throw PageNotFoundException::forPageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddCategories extends BaseMigration
|
||||||
|
|
||||||
class AddCategories extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddLanguages extends BaseMigration
|
||||||
|
|
||||||
class AddLanguages extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPodcasts extends BaseMigration
|
||||||
|
|
||||||
class AddPodcasts extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddEpisodes extends BaseMigration
|
||||||
|
|
||||||
class AddEpisodes extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPlatforms extends BaseMigration
|
||||||
|
|
||||||
class AddPlatforms extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPodcastsPlatforms extends BaseMigration
|
||||||
|
|
||||||
class AddPodcastsPlatforms extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddEpisodeComments extends BaseMigration
|
||||||
|
|
||||||
class AddEpisodeComments extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddLikes extends BaseMigration
|
||||||
|
|
||||||
class AddLikes extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPages extends BaseMigration
|
||||||
|
|
||||||
class AddPages extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPodcastsCategories extends BaseMigration
|
||||||
|
|
||||||
class AddPodcastsCategories extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddClips extends BaseMigration
|
||||||
|
|
||||||
class AddClips extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPersons extends BaseMigration
|
||||||
|
|
||||||
class AddPersons extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddPodcastsPersons extends BaseMigration
|
||||||
|
|
||||||
class AddPodcastsPersons extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddEpisodesPersons extends BaseMigration
|
||||||
|
|
||||||
class AddEpisodesPersons extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddCreditsView extends BaseMigration
|
||||||
|
|
||||||
class AddCreditsView extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddEpisodeIdToPosts extends BaseMigration
|
||||||
|
|
||||||
class AddEpisodeIdToPosts extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddCreatedByToPosts extends BaseMigration
|
||||||
|
|
||||||
class AddCreatedByToPosts extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
34
app/Database/Migrations/BaseMigration.php
Normal file
34
app/Database/Migrations/BaseMigration.php
Normal file
@ -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;
|
namespace App\Database\Seeds;
|
||||||
|
|
||||||
|
use App\Entities\Episode;
|
||||||
|
use App\Entities\Podcast;
|
||||||
use App\Models\EpisodeModel;
|
use App\Models\EpisodeModel;
|
||||||
use App\Models\PodcastModel;
|
use App\Models\PodcastModel;
|
||||||
use CodeIgniter\Database\Seeder;
|
use CodeIgniter\Database\Seeder;
|
||||||
|
use Exception;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
use GeoIp2\Exception\AddressNotFoundException;
|
use GeoIp2\Exception\AddressNotFoundException;
|
||||||
@ -41,162 +44,166 @@ class FakePodcastsAnalyticsSeeder extends Seeder
|
|||||||
|
|
||||||
$podcast = (new PodcastModel())->first();
|
$podcast = (new PodcastModel())->first();
|
||||||
|
|
||||||
if ($podcast !== null) {
|
if (! $podcast instanceof Podcast) {
|
||||||
$firstEpisode = (new EpisodeModel())
|
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
|
||||||
->selectMin('published_at')
|
}
|
||||||
->first();
|
|
||||||
|
|
||||||
for (
|
$firstEpisode = (new EpisodeModel())
|
||||||
$date = strtotime((string) $firstEpisode->published_at);
|
->selectMin('published_at')
|
||||||
$date < strtotime('now');
|
->first();
|
||||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
|
||||||
) {
|
|
||||||
$analyticsPodcasts = [];
|
|
||||||
$analyticsPodcastsByHour = [];
|
|
||||||
$analyticsPodcastsByCountry = [];
|
|
||||||
$analyticsPodcastsByEpisode = [];
|
|
||||||
$analyticsPodcastsByPlayer = [];
|
|
||||||
$analyticsPodcastsByRegion = [];
|
|
||||||
|
|
||||||
$episodes = (new EpisodeModel())
|
if (! $firstEpisode instanceof Episode) {
|
||||||
->where('podcast_id', $podcast->id)
|
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
|
||||||
->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;
|
|
||||||
|
|
||||||
for (
|
for (
|
||||||
$lineNumber = 0;
|
$date = strtotime((string) $firstEpisode->published_at);
|
||||||
$lineNumber < rand(1, (int) $probability1);
|
$date < strtotime('now');
|
||||||
++$lineNumber
|
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||||
) {
|
) {
|
||||||
$probability2 = floor(exp(6 - $age / 20)) + 10;
|
$analyticsPodcasts = [];
|
||||||
|
$analyticsPodcastsByHour = [];
|
||||||
|
$analyticsPodcastsByCountry = [];
|
||||||
|
$analyticsPodcastsByEpisode = [];
|
||||||
|
$analyticsPodcastsByPlayer = [];
|
||||||
|
$analyticsPodcastsByRegion = [];
|
||||||
|
|
||||||
$player =
|
$episodes = (new EpisodeModel())
|
||||||
$jsonUserAgents[
|
->where('podcast_id', $podcast->id)
|
||||||
rand(1, count($jsonUserAgents) - 1)
|
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||||
];
|
->findAll();
|
||||||
$service =
|
foreach ($episodes as $episode) {
|
||||||
$jsonRSSUserAgents[
|
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||||
rand(1, count($jsonRSSUserAgents) - 1)
|
$probability1 = floor(exp(3 - $age / 40)) + 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 =
|
for (
|
||||||
rand(0, 255) .
|
$lineNumber = 0;
|
||||||
'.' .
|
$lineNumber < rand(1, (int) $probability1);
|
||||||
rand(0, 255) .
|
++$lineNumber
|
||||||
'.' .
|
) {
|
||||||
rand(0, 255) .
|
$probability2 = floor(exp(6 - $age / 20)) + 10;
|
||||||
'.' .
|
|
||||||
rand(0, 255);
|
|
||||||
|
|
||||||
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
|
$player =
|
||||||
|
$jsonUserAgents[
|
||||||
$countryCode = 'N/A';
|
rand(1, count($jsonUserAgents) - 1)
|
||||||
$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,
|
|
||||||
];
|
];
|
||||||
|
$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
|
$hits = rand(0, (int) $probability2);
|
||||||
->table('analytics_podcasts')
|
|
||||||
->ignore(true)
|
$analyticsPodcasts[] = [
|
||||||
->insertBatch($analyticsPodcasts);
|
'podcast_id' => $podcast->id,
|
||||||
$this->db
|
'date' => date('Y-m-d', $date),
|
||||||
->table('analytics_podcasts_by_hour')
|
'duration' => rand(60, 3600),
|
||||||
->ignore(true)
|
'bandwidth' => rand(1000000, 10000000),
|
||||||
->insertBatch($analyticsPodcastsByHour);
|
'hits' => $hits,
|
||||||
$this->db
|
'unique_listeners' => $hits,
|
||||||
->table('analytics_podcasts_by_country')
|
];
|
||||||
->ignore(true)
|
$analyticsPodcastsByHour[] = [
|
||||||
->insertBatch($analyticsPodcastsByCountry);
|
'podcast_id' => $podcast->id,
|
||||||
$this->db
|
'date' => date('Y-m-d', $date),
|
||||||
->table('analytics_podcasts_by_episode')
|
'hour' => rand(0, 23),
|
||||||
->ignore(true)
|
'hits' => $hits,
|
||||||
->insertBatch($analyticsPodcastsByEpisode);
|
];
|
||||||
$this->db
|
$analyticsPodcastsByCountry[] = [
|
||||||
->table('analytics_podcasts_by_player')
|
'podcast_id' => $podcast->id,
|
||||||
->ignore(true)
|
'date' => date('Y-m-d', $date),
|
||||||
->insertBatch($analyticsPodcastsByPlayer);
|
'country_code' => $countryCode,
|
||||||
$this->db
|
'hits' => $hits,
|
||||||
->table('analytics_podcasts_by_region')
|
];
|
||||||
->ignore(true)
|
$analyticsPodcastsByEpisode[] = [
|
||||||
->insertBatch($analyticsPodcastsByRegion);
|
'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;
|
namespace App\Database\Seeds;
|
||||||
|
|
||||||
|
use App\Entities\Episode;
|
||||||
|
use App\Entities\Podcast;
|
||||||
use App\Models\EpisodeModel;
|
use App\Models\EpisodeModel;
|
||||||
use App\Models\PodcastModel;
|
use App\Models\PodcastModel;
|
||||||
|
|
||||||
use CodeIgniter\Database\Seeder;
|
use CodeIgniter\Database\Seeder;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
class FakeWebsiteAnalyticsSeeder extends Seeder
|
class FakeWebsiteAnalyticsSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -183,86 +186,90 @@ class FakeWebsiteAnalyticsSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$podcast = (new PodcastModel())->first();
|
$podcast = (new PodcastModel())->first();
|
||||||
|
|
||||||
if ($podcast) {
|
if (! $podcast instanceof Podcast) {
|
||||||
$firstEpisode = (new EpisodeModel())
|
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate a podcast with episodes first.\n");
|
||||||
->selectMin('published_at')
|
}
|
||||||
->first();
|
|
||||||
|
|
||||||
for (
|
$firstEpisode = (new EpisodeModel())
|
||||||
$date = strtotime((string) $firstEpisode->published_at);
|
->selectMin('published_at')
|
||||||
$date < strtotime('now');
|
->first();
|
||||||
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
|
||||||
) {
|
|
||||||
$websiteByBrowser = [];
|
|
||||||
$websiteByEntryPage = [];
|
|
||||||
$websiteByReferer = [];
|
|
||||||
|
|
||||||
$episodes = (new EpisodeModel())
|
if (! $firstEpisode instanceof Episode) {
|
||||||
->where('podcast_id', $podcast->id)
|
throw new Exception("COULD NOT POPULATE DATABASE:\n\tCreate an episode first.");
|
||||||
->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;
|
|
||||||
|
|
||||||
for (
|
for (
|
||||||
$lineNumber = 0;
|
$date = strtotime((string) $firstEpisode->published_at);
|
||||||
$lineNumber < rand(1, $probability1);
|
$date < strtotime('now');
|
||||||
++$lineNumber
|
$date = strtotime(date('Y-m-d', $date) . ' +1 day')
|
||||||
) {
|
) {
|
||||||
$probability2 = (int) floor(exp(6 - $age / 20)) + 10;
|
$websiteByBrowser = [];
|
||||||
|
$websiteByEntryPage = [];
|
||||||
|
$websiteByReferer = [];
|
||||||
|
|
||||||
$domain =
|
$episodes = (new EpisodeModel())
|
||||||
$this->domains[rand(0, count($this->domains) - 1)];
|
->where('podcast_id', $podcast->id)
|
||||||
$keyword =
|
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||||
$this->keywords[
|
->findAll();
|
||||||
rand(0, count($this->keywords) - 1)
|
foreach ($episodes as $episode) {
|
||||||
];
|
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||||
$browser =
|
$probability1 = (int) floor(exp(3 - $age / 40)) + 1;
|
||||||
$this->browsers[
|
|
||||||
rand(0, count($this->browsers) - 1)
|
|
||||||
];
|
|
||||||
|
|
||||||
$hits = rand(0, $probability2);
|
for (
|
||||||
|
$lineNumber = 0;
|
||||||
|
$lineNumber < rand(1, $probability1);
|
||||||
|
++$lineNumber
|
||||||
|
) {
|
||||||
|
$probability2 = (int) floor(exp(6 - $age / 20)) + 10;
|
||||||
|
|
||||||
$websiteByBrowser[] = [
|
$domain =
|
||||||
'podcast_id' => $podcast->id,
|
$this->domains[rand(0, count($this->domains) - 1)];
|
||||||
'date' => date('Y-m-d', $date),
|
$keyword =
|
||||||
'browser' => $browser,
|
$this->keywords[
|
||||||
'hits' => $hits,
|
rand(0, count($this->keywords) - 1)
|
||||||
];
|
];
|
||||||
$websiteByEntryPage[] = [
|
$browser =
|
||||||
'podcast_id' => $podcast->id,
|
$this->browsers[
|
||||||
'date' => date('Y-m-d', $date),
|
rand(0, count($this->browsers) - 1)
|
||||||
'entry_page_url' => $episode->link,
|
|
||||||
'hits' => $hits,
|
|
||||||
];
|
];
|
||||||
$websiteByReferer[] = [
|
|
||||||
'podcast_id' => $podcast->id,
|
$hits = rand(0, $probability2);
|
||||||
'date' => date('Y-m-d', $date),
|
|
||||||
'referer_url' => 'http://' . $domain . '/?q=' . $keyword,
|
$websiteByBrowser[] = [
|
||||||
'domain' => $domain,
|
'podcast_id' => $podcast->id,
|
||||||
'keywords' => $keyword,
|
'date' => date('Y-m-d', $date),
|
||||||
'hits' => $hits,
|
'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
|
public function getUser(): ?User
|
||||||
{
|
{
|
||||||
|
/** @var ?User */
|
||||||
return (new UserModel())->find($this->created_by);
|
return (new UserModel())->find($this->created_by);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ class Credit extends Entity
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
return lang("PersonsTaxonomy.persons.{$this->person_group}.label");
|
return lang("PersonsTaxonomy.persons.{$this->person_group}.label");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ class Credit extends Entity
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
return lang("PersonsTaxonomy.persons.{$this->person_group}.roles.{$this->person_role}.label");
|
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\Entities\Transcript;
|
||||||
use Modules\Media\Models\MediaModel;
|
use Modules\Media\Models\MediaModel;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use SimpleXMLElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@ -619,13 +620,19 @@ class Episode extends Entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
helper('rss');
|
helper('rss');
|
||||||
$customRssArray = rss_to_array(
|
|
||||||
simplexml_load_string(
|
$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>' .
|
'<?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 .
|
$customRssString .
|
||||||
'</item></channel></rss>',
|
'</item></channel></rss>',
|
||||||
),
|
);
|
||||||
)['elements'][0]['elements'][0];
|
|
||||||
|
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)) {
|
if (array_key_exists('elements', $customRssArray)) {
|
||||||
$this->attributes['custom_rss'] = json_encode($customRssArray['elements']);
|
$this->attributes['custom_rss'] = json_encode($customRssArray['elements']);
|
||||||
|
@ -21,6 +21,7 @@ use CodeIgniter\Files\File;
|
|||||||
use CodeIgniter\HTTP\Files\UploadedFile;
|
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||||
use CodeIgniter\I18n\Time;
|
use CodeIgniter\I18n\Time;
|
||||||
use CodeIgniter\Shield\Entities\User;
|
use CodeIgniter\Shield\Entities\User;
|
||||||
|
use Exception;
|
||||||
use League\CommonMark\Environment\Environment;
|
use League\CommonMark\Environment\Environment;
|
||||||
use League\CommonMark\Extension\Autolink\AutolinkExtension;
|
use League\CommonMark\Extension\Autolink\AutolinkExtension;
|
||||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||||
@ -260,7 +261,13 @@ class Podcast extends Entity
|
|||||||
public function getCover(): Image
|
public function getCover(): Image
|
||||||
{
|
{
|
||||||
if (! $this->cover instanceof 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;
|
return $this->cover;
|
||||||
|
@ -40,7 +40,9 @@ if (! function_exists('current_domain')) {
|
|||||||
*/
|
*/
|
||||||
function current_domain(): string
|
function current_domain(): string
|
||||||
{
|
{
|
||||||
|
/** @var URI $uri */
|
||||||
$uri = current_url(true);
|
$uri = current_url(true);
|
||||||
|
|
||||||
return $uri->getHost() . ($uri->getPort() ? ':' . $uri->getPort() : '');
|
return $uri->getHost() . ($uri->getPort() ? ':' . $uri->getPort() : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Entities\Actor;
|
||||||
|
use App\Entities\Episode;
|
||||||
use App\Entities\EpisodeComment;
|
use App\Entities\EpisodeComment;
|
||||||
use App\Libraries\CommentObject;
|
use App\Libraries\CommentObject;
|
||||||
use CodeIgniter\Database\BaseBuilder;
|
use CodeIgniter\Database\BaseBuilder;
|
||||||
@ -297,7 +299,15 @@ class EpisodeCommentModel extends UuidModel
|
|||||||
$episode = model(EpisodeModel::class, false)
|
$episode = model(EpisodeModel::class, false)
|
||||||
->find((int) $data['data']['episode_id']);
|
->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;
|
return $data;
|
||||||
|
@ -15,6 +15,7 @@ use App\Entities\Like;
|
|||||||
use Michalsn\Uuid\UuidModel;
|
use Michalsn\Uuid\UuidModel;
|
||||||
use Modules\Fediverse\Activities\LikeActivity;
|
use Modules\Fediverse\Activities\LikeActivity;
|
||||||
use Modules\Fediverse\Activities\UndoActivity;
|
use Modules\Fediverse\Activities\UndoActivity;
|
||||||
|
use Modules\Fediverse\Entities\Activity;
|
||||||
use Modules\Fediverse\Entities\Actor;
|
use Modules\Fediverse\Entities\Actor;
|
||||||
use Modules\Fediverse\Models\ActivityModel;
|
use Modules\Fediverse\Models\ActivityModel;
|
||||||
|
|
||||||
@ -113,6 +114,11 @@ class LikeModel extends UuidModel
|
|||||||
])
|
])
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
if (! $activity instanceof Activity) {
|
||||||
|
// no like activity found, do nothing
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$likeActivity = new LikeActivity();
|
$likeActivity = new LikeActivity();
|
||||||
$likeActivity
|
$likeActivity
|
||||||
->set('id', url_to('activity', esc($actor->username), $activity->id))
|
->set('id', url_to('activity', esc($actor->username), $activity->id))
|
||||||
|
@ -439,12 +439,14 @@ class PodcastModel extends Model
|
|||||||
if ($podcast instanceof Podcast) {
|
if ($podcast instanceof Podcast) {
|
||||||
$podcastActor = (new ActorModel())->find($podcast->actor_id);
|
$podcastActor = (new ActorModel())->find($podcast->actor_id);
|
||||||
|
|
||||||
if ($podcastActor) {
|
if (! $podcastActor instanceof Actor) {
|
||||||
$podcastActor->avatar_image_url = $podcast->cover->federation_url;
|
return $data;
|
||||||
$podcastActor->avatar_image_mimetype = $podcast->cover->federation_mimetype;
|
|
||||||
|
|
||||||
(new ActorModel())->update($podcast->actor_id, $podcastActor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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;
|
return $data;
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Analytics\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddIsOwnerToUsers extends BaseMigration
|
||||||
|
|
||||||
class AddIsOwnerToUsers extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -68,15 +68,15 @@ if (! function_exists('interact_as_actor')) {
|
|||||||
/**
|
/**
|
||||||
* Get the actor the user is currently interacting as
|
* Get the actor the user is currently interacting as
|
||||||
*/
|
*/
|
||||||
function interact_as_actor(): Actor | false
|
function interact_as_actor(): ?Actor
|
||||||
{
|
{
|
||||||
if (! auth()->loggedIn()) {
|
if (! auth()->loggedIn()) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$session = session();
|
$session = session();
|
||||||
if (! $session->has('interact_as_actor_id')) {
|
if (! $session->has('interact_as_actor_id')) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return model(ActorModel::class, false)->getActorById($session->get('interact_as_actor_id'));
|
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\Controller;
|
||||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||||
|
use CodeIgniter\HTTP\IncomingRequest;
|
||||||
use CodeIgniter\HTTP\RedirectResponse;
|
use CodeIgniter\HTTP\RedirectResponse;
|
||||||
use CodeIgniter\HTTP\Response;
|
use CodeIgniter\HTTP\Response;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
@ -23,6 +24,13 @@ use Modules\Fediverse\Objects\OrderedCollectionPage;
|
|||||||
|
|
||||||
class PostController extends Controller
|
class PostController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Instance of the main Request object.
|
||||||
|
*
|
||||||
|
* @var IncomingRequest
|
||||||
|
*/
|
||||||
|
protected $request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @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;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\Fediverse\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
class AddNotifications extends BaseMigration
|
||||||
|
|
||||||
class AddNotifications extends Migration
|
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Media\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Media\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\PremiumPodcasts\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\WebSub\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Modules\WebSub\Database\Migrations;
|
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
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,4 @@ parameters:
|
|||||||
- ENVIRONMENT
|
- ENVIRONMENT
|
||||||
- SODIUM_LIBRARY_VERSION
|
- SODIUM_LIBRARY_VERSION
|
||||||
ignoreErrors:
|
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#'
|
- '#^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);
|
$this->setPrivateProperty($model, 'tempUseSoftDeletes', true);
|
||||||
|
|
||||||
$object = $model->first();
|
$object = $model->first();
|
||||||
|
|
||||||
|
if (! is_object($object)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$model->delete($object->id);
|
$model->delete($object->id);
|
||||||
|
|
||||||
// The model should no longer find it
|
// The model should no longer find it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user