mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-27 20:21:59 +02:00
fix(activity-pub): get database records using new model instances
update types and some remap logic
This commit is contained in:
parent
4a28127bc4
commit
92536ddb38
@ -34,7 +34,7 @@ class PermissionModel extends MythAuthPermissionModel
|
||||
$groupPermissions = $this->db
|
||||
->table('auth_groups_permissions')
|
||||
->select('id, auth_permissions.name')
|
||||
->join('auth_permissions', 'auth_permissions.id = permission_id', 'inner',)
|
||||
->join('auth_permissions', 'auth_permissions.id = permission_id', 'inner')
|
||||
->where('group_id', $groupId)
|
||||
->get()
|
||||
->getResultObject();
|
||||
|
@ -123,7 +123,7 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void {
|
||||
* @param Note $note
|
||||
*/
|
||||
Events::on('on_note_add', function ($note): void {
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$note = $note->reply_to_note;
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ Events::on('on_note_add', function ($note): void {
|
||||
* @param Note $note
|
||||
*/
|
||||
Events::on('on_note_remove', function ($note): void {
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
Events::trigger('on_note_remove', $note->reply_to_note);
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ Events::on('on_note_reblog', function ($actor, $note): void {
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
|
||||
}
|
||||
});
|
||||
@ -239,7 +239,7 @@ Events::on('on_note_undo_reblog', function ($reblogNote): void {
|
||||
cache()
|
||||
->deleteMatching("page_note#{$reblogNote->id}*");
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ Events::on('on_note_favourite', function ($actor, $note): void {
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ Events::on('on_note_undo_favourite', function ($actor, $note): void {
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
|
||||
}
|
||||
|
||||
|
@ -27,19 +27,24 @@ class ContributorController extends BaseController
|
||||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
$this->podcast = (new PodcastModel())->getPodcastById((int) $params[0]);
|
||||
|
||||
if (count($params) <= 1) {
|
||||
return $this->{$method}();
|
||||
if (count($params) === 0) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) === null) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->podcast = $podcast;
|
||||
|
||||
if (
|
||||
($this->user = (new UserModel())->getPodcastContributor((int) $params[1], (int) $params[0],)) !== null
|
||||
count($params) > 1 &&
|
||||
($this->user = (new UserModel())->getPodcastContributor((int) $params[1], (int) $params[0])) === null
|
||||
) {
|
||||
return $this->{$method}();
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
return $this->{$method}();
|
||||
}
|
||||
|
||||
public function list(): string
|
||||
@ -57,7 +62,7 @@ class ContributorController extends BaseController
|
||||
public function view(): string
|
||||
{
|
||||
$data = [
|
||||
'contributor' => (new UserModel())->getPodcastContributor($this->user->id, $this->podcast->id,),
|
||||
'contributor' => (new UserModel())->getPodcastContributor($this->user->id, $this->podcast->id),
|
||||
];
|
||||
|
||||
replace_breadcrumb_params([
|
||||
@ -173,7 +178,7 @@ class ContributorController extends BaseController
|
||||
|
||||
$podcastModel = new PodcastModel();
|
||||
if (
|
||||
! $podcastModel->removePodcastContributor($this->user->id, $this->podcast->id,)
|
||||
! $podcastModel->removePodcastContributor($this->user->id, $this->podcast->id)
|
||||
) {
|
||||
return redirect()
|
||||
->back()
|
||||
|
@ -33,11 +33,13 @@ class EpisodeController extends BaseController
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) === null
|
||||
($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->podcast = $podcast;
|
||||
|
||||
if (count($params) > 1) {
|
||||
if (
|
||||
! ($this->episode = (new EpisodeModel())
|
||||
@ -135,7 +137,7 @@ class EpisodeController extends BaseController
|
||||
'audio_file' => $this->request->getFile('audio_file'),
|
||||
'description_markdown' => $this->request->getPost('description'),
|
||||
'image' => $image,
|
||||
'location' => new Location($this->request->getPost('location_name'),),
|
||||
'location' => new Location($this->request->getPost('location_name')),
|
||||
'transcript' => $this->request->getFile('transcript'),
|
||||
'chapters' => $this->request->getFile('chapters'),
|
||||
'parental_advisory' =>
|
||||
@ -276,7 +278,7 @@ class EpisodeController extends BaseController
|
||||
}
|
||||
} elseif ($transcriptChoice === 'remote-url') {
|
||||
if (
|
||||
($transcriptFileRemoteUrl = $this->request->getPost('transcript_file_remote_url',)) &&
|
||||
($transcriptFileRemoteUrl = $this->request->getPost('transcript_file_remote_url')) &&
|
||||
(($transcriptFile = $this->episode->transcript_file) &&
|
||||
$transcriptFile !== null)
|
||||
) {
|
||||
@ -295,7 +297,7 @@ class EpisodeController extends BaseController
|
||||
}
|
||||
} elseif ($chaptersChoice === 'remote-url') {
|
||||
if (
|
||||
($chaptersFileRemoteUrl = $this->request->getPost('chapters_file_remote_url',)) &&
|
||||
($chaptersFileRemoteUrl = $this->request->getPost('chapters_file_remote_url')) &&
|
||||
(($chaptersFile = $this->episode->chapters_file) &&
|
||||
$chaptersFile !== null)
|
||||
) {
|
||||
|
@ -31,7 +31,7 @@ class EpisodePersonController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) &&
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) &&
|
||||
($this->episode = (new EpisodeModel())
|
||||
->where([
|
||||
'id' => $params[1],
|
||||
|
@ -27,7 +27,7 @@ class PersonController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->person = (new PersonModel())->getPersonById((int) $params[0],)) !== null
|
||||
($this->person = (new PersonModel())->getPersonById((int) $params[0])) !== null
|
||||
) {
|
||||
return $this->{$method}();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class PodcastController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) !== null
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) !== null
|
||||
) {
|
||||
return $this->{$method}();
|
||||
}
|
||||
@ -45,7 +45,7 @@ class PodcastController extends BaseController
|
||||
{
|
||||
if (! has_permission('podcasts-list')) {
|
||||
$data = [
|
||||
'podcasts' => (new PodcastModel())->getUserPodcasts((int) user_id(),),
|
||||
'podcasts' => (new PodcastModel())->getUserPodcasts((int) user_id()),
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
@ -162,7 +162,7 @@ class PodcastController extends BaseController
|
||||
$data = [
|
||||
'languageOptions' => $languageOptions,
|
||||
'categoryOptions' => $categoryOptions,
|
||||
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE'),),
|
||||
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE')),
|
||||
];
|
||||
|
||||
return view('admin/podcast/create', $data);
|
||||
@ -207,7 +207,7 @@ class PodcastController extends BaseController
|
||||
'publisher' => $this->request->getPost('publisher'),
|
||||
'type' => $this->request->getPost('type'),
|
||||
'copyright' => $this->request->getPost('copyright'),
|
||||
'location' => new Location($this->request->getPost('location_name'),),
|
||||
'location' => new Location($this->request->getPost('location_name')),
|
||||
'payment_pointer' => $this->request->getPost(
|
||||
'payment_pointer'
|
||||
) === '' ? null : $this->request->getPost('payment_pointer'),
|
||||
|
@ -56,7 +56,7 @@ class PodcastImportController extends BaseController
|
||||
$data = [
|
||||
'languageOptions' => $languageOptions,
|
||||
'categoryOptions' => $categoryOptions,
|
||||
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE'),),
|
||||
'browserLang' => get_browser_language($this->request->getServer('HTTP_ACCEPT_LANGUAGE')),
|
||||
];
|
||||
|
||||
return view('admin/podcast/import', $data);
|
||||
@ -132,10 +132,10 @@ class PodcastImportController extends BaseController
|
||||
|
||||
$podcast = new Podcast([
|
||||
'name' => $this->request->getPost('name'),
|
||||
'imported_feed_url' => $this->request->getPost('imported_feed_url',),
|
||||
'new_feed_url' => base_url(route_to('podcast_feed', $this->request->getPost('name')),),
|
||||
'imported_feed_url' => $this->request->getPost('imported_feed_url'),
|
||||
'new_feed_url' => base_url(route_to('podcast_feed', $this->request->getPost('name'))),
|
||||
'title' => (string) $feed->channel[0]->title,
|
||||
'description_markdown' => $converter->convert($channelDescriptionHtml,),
|
||||
'description_markdown' => $converter->convert($channelDescriptionHtml),
|
||||
'description_html' => $channelDescriptionHtml,
|
||||
'image' => new Image($imageFile),
|
||||
'language_code' => $this->request->getPost('language'),
|
||||
@ -323,7 +323,7 @@ class PodcastImportController extends BaseController
|
||||
property_exists($nsItunes, 'image') && $nsItunes->image !== null &&
|
||||
$nsItunes->image->attributes()['href'] !== null
|
||||
) {
|
||||
$episodeImage = new Image(download_file((string) $nsItunes->image->attributes()['href'],));
|
||||
$episodeImage = new Image(download_file((string) $nsItunes->image->attributes()['href']));
|
||||
} else {
|
||||
$episodeImage = null;
|
||||
}
|
||||
@ -342,8 +342,8 @@ class PodcastImportController extends BaseController
|
||||
'guid' => $item->guid ?? null,
|
||||
'title' => $item->title,
|
||||
'slug' => $slug,
|
||||
'audio_file' => download_file((string) $item->enclosure->attributes()['url'],),
|
||||
'description_markdown' => $converter->convert($itemDescriptionHtml,),
|
||||
'audio_file' => download_file((string) $item->enclosure->attributes()['url']),
|
||||
'description_markdown' => $converter->convert($itemDescriptionHtml),
|
||||
'description_html' => $itemDescriptionHtml,
|
||||
'image' => $episodeImage,
|
||||
'parental_advisory' =>
|
||||
|
@ -27,7 +27,7 @@ class PodcastPersonController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) !== null
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) !== null
|
||||
) {
|
||||
unset($params[0]);
|
||||
return $this->{$method}(...$params);
|
||||
@ -42,7 +42,7 @@ class PodcastPersonController extends BaseController
|
||||
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'podcastPersons' => (new PersonModel())->getPodcastPersons($this->podcast->id,),
|
||||
'podcastPersons' => (new PersonModel())->getPodcastPersons($this->podcast->id),
|
||||
'personOptions' => (new PersonModel())->getPersonOptions(),
|
||||
'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
|
||||
];
|
||||
|
@ -28,7 +28,7 @@ class PodcastPlatformController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) !== null
|
||||
($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) !== null
|
||||
) {
|
||||
unset($params[0]);
|
||||
return $this->{$method}(...$params);
|
||||
@ -49,7 +49,7 @@ class PodcastPlatformController extends BaseController
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'platformType' => $platformType,
|
||||
'platforms' => (new PlatformModel())->getPlatformsWithLinks($this->podcast->id, $platformType,),
|
||||
'platforms' => (new PlatformModel())->getPlatformsWithLinks($this->podcast->id, $platformType),
|
||||
];
|
||||
|
||||
replace_breadcrumb_params([
|
||||
|
@ -35,20 +35,25 @@ class EpisodeController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0],)) === null
|
||||
($podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->podcast = $podcast;
|
||||
|
||||
if (
|
||||
($this->episode = (new EpisodeModel())->getEpisodeBySlug($params[0], $params[1],)) !== null
|
||||
($episode = (new EpisodeModel())->getEpisodeBySlug($params[0], $params[1])) === null
|
||||
) {
|
||||
unset($params[1]);
|
||||
unset($params[0]);
|
||||
return $this->{$method}(...$params);
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
$this->episode = $episode;
|
||||
|
||||
unset($params[1]);
|
||||
unset($params[0]);
|
||||
|
||||
return $this->{$method}(...$params);
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
|
@ -155,7 +155,7 @@ class InstallController extends Controller
|
||||
|
||||
if (! $this->validate($rules)) {
|
||||
return redirect()
|
||||
->to((host_url() === null ? config('App') ->baseURL : host_url()) . config('App')->installGateway,)
|
||||
->to((host_url() === null ? config('App') ->baseURL : host_url()) . config('App')->installGateway)
|
||||
->withInput()
|
||||
->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
@ -173,7 +173,7 @@ class InstallController extends Controller
|
||||
helper('text');
|
||||
|
||||
// redirect to full install url with new baseUrl input
|
||||
return redirect()->to(reduce_double_slashes($baseUrl . '/' . config('App')->installGateway,));
|
||||
return redirect()->to(reduce_double_slashes($baseUrl . '/' . config('App')->installGateway));
|
||||
}
|
||||
|
||||
public function databaseConfig(): string
|
||||
@ -198,10 +198,10 @@ class InstallController extends Controller
|
||||
}
|
||||
|
||||
self::writeEnv([
|
||||
'database.default.hostname' => $this->request->getPost('db_hostname',),
|
||||
'database.default.hostname' => $this->request->getPost('db_hostname'),
|
||||
'database.default.database' => $this->request->getPost('db_name'),
|
||||
'database.default.username' => $this->request->getPost('db_username',),
|
||||
'database.default.password' => $this->request->getPost('db_password',),
|
||||
'database.default.username' => $this->request->getPost('db_username'),
|
||||
'database.default.password' => $this->request->getPost('db_password'),
|
||||
'database.default.DBPrefix' => $this->request->getPost('db_prefix'),
|
||||
]);
|
||||
|
||||
|
@ -39,8 +39,12 @@ class NoteController extends ActivityPubNoteController
|
||||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (count($params) < 2) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0],)) === null
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
@ -48,11 +52,13 @@ class NoteController extends ActivityPubNoteController
|
||||
$this->actor = $this->podcast->actor;
|
||||
|
||||
if (
|
||||
count($params) > 1 &&
|
||||
! ($this->note = (new NoteModel())->getNoteById($params[1]))
|
||||
($note = (new NoteModel())->getNoteById($params[1])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->note = $note;
|
||||
|
||||
unset($params[0]);
|
||||
unset($params[1]);
|
||||
|
||||
@ -125,7 +131,7 @@ class NoteController extends ActivityPubNoteController
|
||||
if (
|
||||
$episodeUri &&
|
||||
($params = extract_params_from_episode_uri(new URI($episodeUri))) &&
|
||||
($episode = (new EpisodeModel())->getEpisodeBySlug($params['podcastName'], $params['episodeSlug'],))
|
||||
($episode = (new EpisodeModel())->getEpisodeBySlug($params['podcastName'], $params['episodeSlug']))
|
||||
) {
|
||||
$newNote->episode_id = $episode->id;
|
||||
}
|
||||
@ -135,7 +141,7 @@ class NoteController extends ActivityPubNoteController
|
||||
$noteModel = new NoteModel();
|
||||
if (
|
||||
! $noteModel
|
||||
->addNote($newNote, ! (bool) $newNote->episode_id, true,)
|
||||
->addNote($newNote, ! (bool) $newNote->episode_id, true)
|
||||
) {
|
||||
return redirect()
|
||||
->back()
|
||||
|
@ -16,7 +16,7 @@ use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
|
||||
class PageController extends BaseController
|
||||
{
|
||||
protected ?Page $page = null;
|
||||
protected Page $page;
|
||||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
@ -25,12 +25,14 @@ class PageController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
$this->page = (new PageModel())->where('slug', $params[0])->first()
|
||||
($page = (new PageModel())->where('slug', $params[0])->first()) === null
|
||||
) {
|
||||
return $this->{$method}();
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
$this->page = $page;
|
||||
|
||||
return $this->{$method}();
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
|
@ -30,13 +30,15 @@ class PodcastController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0],)) !== null
|
||||
($podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
|
||||
) {
|
||||
unset($params[0]);
|
||||
return $this->{$method}(...$params);
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
$this->podcast = $podcast;
|
||||
|
||||
unset($params[0]);
|
||||
return $this->{$method}(...$params);
|
||||
}
|
||||
|
||||
public function activity(): string
|
||||
@ -61,7 +63,7 @@ class PodcastController extends BaseController
|
||||
if (! ($cachedView = cache($cacheName))) {
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'notes' => (new NoteModel())->getActorPublishedNotes($this->podcast->actor_id,),
|
||||
'notes' => (new NoteModel())->getActorPublishedNotes($this->podcast->actor_id),
|
||||
];
|
||||
|
||||
// if user is logged in then send to the authenticated activity view
|
||||
|
@ -277,7 +277,7 @@ class AuthSeeder extends Seeder
|
||||
foreach ($action['has_permission'] as $role) {
|
||||
// link permission to specified groups
|
||||
$dataGroupsPermissions[] = [
|
||||
'group_id' => $this->getGroupIdByName($role, $dataGroups,),
|
||||
'group_id' => $this->getGroupIdByName($role, $dataGroups),
|
||||
'permission_id' => $permissionId,
|
||||
];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class FakePodcastsAnalyticsSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$jsonUserAgents = json_decode(
|
||||
file_get_contents('https://raw.githubusercontent.com/opawg/user-agents/master/src/user-agents.json',),
|
||||
file_get_contents('https://raw.githubusercontent.com/opawg/user-agents/master/src/user-agents.json'),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR,
|
||||
@ -63,7 +63,7 @@ class FakePodcastsAnalyticsSeeder extends Seeder
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->findAll();
|
||||
foreach ($episodes as $episode) {
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400,);
|
||||
$age = floor(($date - strtotime((string) $episode->published_at)) / 86400);
|
||||
$probability1 = floor(exp(3 - $age / 40)) + 1;
|
||||
|
||||
for (
|
||||
@ -97,7 +97,7 @@ class FakePodcastsAnalyticsSeeder extends Seeder
|
||||
'.' .
|
||||
rand(0, 255);
|
||||
|
||||
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb',);
|
||||
$cityReader = new Reader(WRITEPATH . 'uploads/GeoLite2-City/GeoLite2-City.mmdb');
|
||||
|
||||
$countryCode = 'N/A';
|
||||
$regionCode = 'N/A';
|
||||
|
@ -396,7 +396,7 @@ class Episode extends Entity
|
||||
|
||||
public function getLink(): string
|
||||
{
|
||||
return base_url(route_to('episode', $this->getPodcast() ->name, $this->attributes['slug'],));
|
||||
return base_url(route_to('episode', $this->getPodcast() ->name, $this->attributes['slug']));
|
||||
}
|
||||
|
||||
public function getEmbeddablePlayerUrl(string $theme = null): string
|
||||
@ -410,7 +410,7 @@ class Episode extends Entity
|
||||
$this->attributes['slug'],
|
||||
$theme,
|
||||
)
|
||||
: route_to('embeddable-player', $this->getPodcast() ->name, $this->attributes['slug'],),
|
||||
: route_to('embeddable-player', $this->getPodcast() ->name, $this->attributes['slug']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ class Episode extends Entity
|
||||
{
|
||||
if ($this->description === null) {
|
||||
$this->description = trim(
|
||||
preg_replace('~\s+~', ' ', strip_tags($this->attributes['description_html']),),
|
||||
preg_replace('~\s+~', ' ', strip_tags($this->attributes['description_html'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,6 @@ use RuntimeException;
|
||||
/**
|
||||
* @property int|null $episode_id
|
||||
* @property Episode|null $episode
|
||||
* @property Actor $actor
|
||||
* @property Note $reblog_of_note
|
||||
* @property Note $reply_to_note
|
||||
*/
|
||||
class Note extends ActivityPubNote
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ class Podcast extends Entity
|
||||
{
|
||||
if ($this->description === null) {
|
||||
$this->description = trim(
|
||||
(string) preg_replace('~\s+~', ' ', strip_tags($this->attributes['description_html']),),
|
||||
(string) preg_replace('~\s+~', ' ', strip_tags($this->attributes['description_html'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ if (! function_exists('button')) {
|
||||
if ($uri !== '') {
|
||||
return anchor($uri, $label, array_merge([
|
||||
'class' => $buttonClass,
|
||||
], $customAttributes,));
|
||||
], $customAttributes));
|
||||
}
|
||||
|
||||
$defaultButtonAttributes = [
|
||||
|
@ -159,9 +159,9 @@ if (! function_exists('form_multiselect')) {
|
||||
'data-class' => $customExtra['class'],
|
||||
'data-select-text' => lang('Common.forms.multiSelect.selectText'),
|
||||
'data-loading-text' => lang('Common.forms.multiSelect.loadingText'),
|
||||
'data-no-results-text' => lang('Common.forms.multiSelect.noResultsText',),
|
||||
'data-no-choices-text' => lang('Common.forms.multiSelect.noChoicesText',),
|
||||
'data-max-item-text' => lang('Common.forms.multiSelect.maxItemText',),
|
||||
'data-no-results-text' => lang('Common.forms.multiSelect.noResultsText'),
|
||||
'data-no-choices-text' => lang('Common.forms.multiSelect.noChoicesText'),
|
||||
'data-max-item-text' => lang('Common.forms.multiSelect.maxItemText'),
|
||||
];
|
||||
$extra = stringify_attributes(array_merge($defaultExtra, $customExtra));
|
||||
|
||||
|
@ -84,7 +84,7 @@ if (! function_exists('get_rss_feed')) {
|
||||
$recipientElement->addAttribute('split', '100');
|
||||
}
|
||||
$channel
|
||||
->addChild('locked', $podcast->is_locked ? 'yes' : 'no', $podcastNamespace,)
|
||||
->addChild('locked', $podcast->is_locked ? 'yes' : 'no', $podcastNamespace)
|
||||
->addAttribute('owner', $podcast->owner_email);
|
||||
if ($podcast->imported_feed_url !== null) {
|
||||
$channel->addChild('previousUrl', $podcast->imported_feed_url, $podcastNamespace);
|
||||
@ -142,13 +142,13 @@ if (! function_exists('get_rss_feed')) {
|
||||
$personElement->addAttribute(
|
||||
'role',
|
||||
htmlspecialchars(
|
||||
lang("PersonsTaxonomy.persons.{$role->group}.roles.{$role->role}.label", [], 'en',),
|
||||
lang("PersonsTaxonomy.persons.{$role->group}.roles.{$role->role}.label", [], 'en'),
|
||||
),
|
||||
);
|
||||
|
||||
$personElement->addAttribute(
|
||||
'group',
|
||||
htmlspecialchars(lang("PersonsTaxonomy.persons.{$role->group}.label", [], 'en',),),
|
||||
htmlspecialchars(lang("PersonsTaxonomy.persons.{$role->group}.label", [], 'en')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -253,7 +253,7 @@ if (! function_exists('get_rss_feed')) {
|
||||
$transcriptElement->addAttribute('url', $episode->transcript_file_url);
|
||||
$transcriptElement->addAttribute(
|
||||
'type',
|
||||
Mimes::guessTypeFromExtension(pathinfo($episode->transcript_file_url, PATHINFO_EXTENSION,),),
|
||||
Mimes::guessTypeFromExtension(pathinfo($episode->transcript_file_url, PATHINFO_EXTENSION)),
|
||||
);
|
||||
$transcriptElement->addAttribute('language', $podcast->language_code);
|
||||
}
|
||||
@ -281,13 +281,13 @@ if (! function_exists('get_rss_feed')) {
|
||||
$personElement->addAttribute(
|
||||
'role',
|
||||
htmlspecialchars(
|
||||
lang("PersonsTaxonomy.persons.{$role->group}.roles.{$role->role}.label", [], 'en',),
|
||||
lang("PersonsTaxonomy.persons.{$role->group}.roles.{$role->role}.label", [], 'en'),
|
||||
),
|
||||
);
|
||||
|
||||
$personElement->addAttribute(
|
||||
'group',
|
||||
htmlspecialchars(lang("PersonsTaxonomy.persons.{$role->group}.label", [], 'en',),),
|
||||
htmlspecialchars(lang("PersonsTaxonomy.persons.{$role->group}.label", [], 'en')),
|
||||
);
|
||||
|
||||
$personElement->addAttribute('img', $person->image->large_url);
|
||||
|
@ -39,12 +39,17 @@ class ActorController extends Controller
|
||||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (count($params) < 1) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
count($params) > 0 &&
|
||||
! ($this->actor = model('ActorModel')->getActorByUsername($params[0],))
|
||||
($actor = model('ActorModel')->getActorByUsername($params[0])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->actor = $actor;
|
||||
unset($params[0]);
|
||||
|
||||
return $this->{$method}(...$params);
|
||||
@ -109,7 +114,7 @@ class ActorController extends Controller
|
||||
'actor_id' => $payloadActor->id,
|
||||
'in_reply_to_id' => $replyToNote->id,
|
||||
'message' => $payload->object->content,
|
||||
'published_at' => Time::parse($payload->object->published,),
|
||||
'published_at' => Time::parse($payload->object->published),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -295,7 +300,7 @@ class ActorController extends Controller
|
||||
{
|
||||
// get followers for a specific actor
|
||||
$followers = model('ActorModel')
|
||||
->join('activitypub_follows', 'activitypub_follows.actor_id = id', 'inner',)
|
||||
->join('activitypub_follows', 'activitypub_follows.actor_id = id', 'inner')
|
||||
->where('activitypub_follows.target_actor_id', $this->actor->id)
|
||||
->orderBy('activitypub_follows.created_at', 'DESC');
|
||||
|
||||
@ -364,7 +369,7 @@ class ActorController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->to(
|
||||
str_replace('{uri}', urlencode($this->actor->uri), $data->links[$ostatusKey]->template,),
|
||||
str_replace('{uri}', urlencode($this->actor->uri), $data->links[$ostatusKey]->template),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class BlockController extends Controller
|
||||
|
||||
if ($parts = split_handle($handle)) {
|
||||
if (
|
||||
($actor = get_or_create_actor($parts['username'], $parts['domain'],)) === null
|
||||
($actor = get_or_create_actor($parts['username'], $parts['domain'])) === null
|
||||
) {
|
||||
return redirect()
|
||||
->back()
|
||||
|
@ -39,9 +39,16 @@ class NoteController extends Controller
|
||||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (! ($this->note = model('NoteModel')->getNoteById($params[0]))) {
|
||||
if (count($params) < 1) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (($note = model('NoteModel')->getNoteById($params[0])) === null) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->note = $note;
|
||||
|
||||
unset($params[0]);
|
||||
|
||||
return $this->{$method}(...$params);
|
||||
@ -69,7 +76,7 @@ class NoteController extends Controller
|
||||
* get note replies
|
||||
*/
|
||||
$noteReplies = model('NoteModel')
|
||||
->where('in_reply_to_id', service('uuid') ->fromString($this->note->id) ->getBytes(),)
|
||||
->where('in_reply_to_id', service('uuid') ->fromString($this->note->id) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC');
|
||||
|
||||
@ -252,7 +259,7 @@ class NoteController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->to(
|
||||
str_replace('{uri}', urlencode($this->note->uri), $data->links[$ostatusKey]->template,),
|
||||
str_replace('{uri}', urlencode($this->note->uri), $data->links[$ostatusKey]->template),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ use RuntimeException;
|
||||
* @property int $actor_id
|
||||
* @property Actor $actor
|
||||
* @property int|null $target_actor_id
|
||||
* @property Actor|null $target_actor
|
||||
* @property Actor $target_actor
|
||||
* @property string|null $note_id
|
||||
* @property Note|null $note
|
||||
* @property Note $note
|
||||
* @property string $type
|
||||
* @property object $payload
|
||||
* @property string|null $status
|
||||
@ -65,7 +65,7 @@ class Activity extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->actor === null) {
|
||||
$this->actor = model('ActorModel')
|
||||
$this->actor = model('ActorModel', false)
|
||||
->getActorById($this->actor_id);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class Activity extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->target_actor === null) {
|
||||
$this->target_actor = model('ActorModel')
|
||||
$this->target_actor = model('ActorModel', false)
|
||||
->getActorById($this->target_actor_id);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class Activity extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->note === null) {
|
||||
$this->note = model('NoteModel')
|
||||
$this->note = model('NoteModel', false)
|
||||
->getNoteById($this->note_id);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class Actor extends Entity
|
||||
}
|
||||
|
||||
if ($this->followers === null) {
|
||||
$this->followers = (array) model('ActorModel')
|
||||
$this->followers = (array) model('ActorModel', false)
|
||||
->getFollowers($this->id);
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,10 @@ use RuntimeException;
|
||||
* @property string $id
|
||||
* @property string $uri
|
||||
* @property int $actor_id
|
||||
* @property Actor|null $actor
|
||||
* @property Actor $actor
|
||||
* @property string|null $in_reply_to_id
|
||||
* @property bool $is_reply
|
||||
* @property Note|null $reply_to_note
|
||||
* @property string|null $reblog_of_id
|
||||
* @property bool $is_reblog
|
||||
* @property Note|null $reblog_of_note
|
||||
* @property string $message
|
||||
* @property string $message_html
|
||||
@ -44,12 +42,8 @@ class Note extends UuidEntity
|
||||
{
|
||||
protected ?Actor $actor = null;
|
||||
|
||||
protected bool $is_reply = false;
|
||||
|
||||
protected ?Note $reply_to_note = null;
|
||||
|
||||
protected bool $is_reblog = false;
|
||||
|
||||
protected ?Note $reblog_of_note = null;
|
||||
|
||||
protected ?PreviewCard $preview_card = null;
|
||||
@ -97,14 +91,14 @@ class Note extends UuidEntity
|
||||
/**
|
||||
* Returns the note's actor
|
||||
*/
|
||||
public function getActor(): ?Actor
|
||||
public function getActor(): Actor
|
||||
{
|
||||
if ($this->actor_id === null) {
|
||||
throw new RuntimeException('Note must have an actor_id before getting actor.');
|
||||
}
|
||||
|
||||
if ($this->actor === null) {
|
||||
$this->actor = model('ActorModel')
|
||||
$this->actor = model('ActorModel', false)
|
||||
->getActorById($this->actor_id);
|
||||
}
|
||||
|
||||
@ -118,7 +112,7 @@ class Note extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->preview_card === null) {
|
||||
$this->preview_card = model('PreviewCardModel')
|
||||
$this->preview_card = model('PreviewCardModel', false)
|
||||
->getNotePreviewCard($this->id);
|
||||
}
|
||||
|
||||
@ -130,11 +124,6 @@ class Note extends UuidEntity
|
||||
return $this->getPreviewCard() !== null;
|
||||
}
|
||||
|
||||
public function getIsReply(): bool
|
||||
{
|
||||
return $this->in_reply_to_id && ($this->getReplyToNote() !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Note[]
|
||||
*/
|
||||
@ -145,7 +134,7 @@ class Note extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->replies === null) {
|
||||
$this->replies = (array) model('NoteModel')
|
||||
$this->replies = (array) model('NoteModel', false)
|
||||
->getNoteReplies($this->id);
|
||||
}
|
||||
|
||||
@ -164,7 +153,7 @@ class Note extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->reply_to_note === null) {
|
||||
$this->reply_to_note = model('NoteModel')
|
||||
$this->reply_to_note = model('NoteModel', false)
|
||||
->getNoteById($this->in_reply_to_id);
|
||||
}
|
||||
|
||||
@ -181,18 +170,13 @@ class Note extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->reblogs === null) {
|
||||
$this->reblogs = (array) model('NoteModel')
|
||||
$this->reblogs = (array) model('NoteModel', false)
|
||||
->getNoteReblogs($this->id);
|
||||
}
|
||||
|
||||
return $this->reblogs;
|
||||
}
|
||||
|
||||
public function getIsReblog(): bool
|
||||
{
|
||||
return $this->reblog_of_id !== null;
|
||||
}
|
||||
|
||||
public function getReblogOfNote(): ?self
|
||||
{
|
||||
if ($this->reblog_of_id === null) {
|
||||
@ -200,7 +184,7 @@ class Note extends UuidEntity
|
||||
}
|
||||
|
||||
if ($this->reblog_of_note === null) {
|
||||
$this->reblog_of_note = model('NoteModel')
|
||||
$this->reblog_of_note = model('NoteModel', false)
|
||||
->getNoteById($this->reblog_of_id);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ if (! function_exists('split_handle')) {
|
||||
function split_handle(string $handle): array | false
|
||||
{
|
||||
if (
|
||||
! preg_match('~^@?(?P<username>[\w\.\-]+)@(?P<domain>[\w\.\-]+)(?P<port>:[\d]+)?$~', $handle, $matches,)
|
||||
! preg_match('~^@?(?P<username>[\w\.\-]+)@(?P<domain>[\w\.\-]+)(?P<port>:[\d]+)?$~', $handle, $matches)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@ -171,7 +171,7 @@ if (! function_exists('create_preview_card_from_url')) {
|
||||
]);
|
||||
|
||||
if (
|
||||
! ($newPreviewCardId = model('PreviewCardModel')->insert($newPreviewCard, true,))
|
||||
! ($newPreviewCardId = model('PreviewCardModel')->insert($newPreviewCard, true))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
@ -194,7 +194,7 @@ if (! function_exists('get_or_create_preview_card_from_url')) {
|
||||
// check if preview card has already been generated
|
||||
if (
|
||||
$previewCard = model('PreviewCardModel')
|
||||
->getPreviewCardFromUrl((string) $url,)
|
||||
->getPreviewCardFromUrl((string) $url)
|
||||
) {
|
||||
return $previewCard;
|
||||
}
|
||||
@ -361,7 +361,7 @@ if (! function_exists('linkify')) {
|
||||
if (
|
||||
$actor = model(
|
||||
'ActorModel',
|
||||
)->getActorByUsername($match['username'], $match['domain'],)
|
||||
)->getActorByUsername($match['username'], $match['domain'])
|
||||
) {
|
||||
// TODO: check that host is local to remove target blank?
|
||||
return '<' .
|
||||
@ -394,11 +394,11 @@ if (! function_exists('linkify')) {
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
$actor = model('ActorModel',)
|
||||
$actor = model('ActorModel')
|
||||
->getActorByUsername($match['username'])
|
||||
) {
|
||||
return '<' .
|
||||
array_push($links, anchor($actor->uri, $match[0]),) .
|
||||
array_push($links, anchor($actor->uri, $match[0])) .
|
||||
'>';
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class HttpSignature
|
||||
([\w\-\.#\/@]+)
|
||||
)",
|
||||
algorithm="(?P<algorithm>[\w\-]+)",
|
||||
(headers="\(request-target\) (?P<headers>[\w\\-\s]+)",)?
|
||||
(headers="\(request-target\) (?P<headers>[\w\\-\s]+)")?
|
||||
signature="(?P<signature>[\w+\/]+={0,2})"
|
||||
/x';
|
||||
|
||||
|
@ -129,7 +129,7 @@ class ActorModel extends Model
|
||||
config('ActivityPub')
|
||||
->cachePrefix . "actor#{$actorId}_followers";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->join('activitypub_follows', 'activitypub_follows.actor_id = id', 'inner',)
|
||||
$found = $this->join('activitypub_follows', 'activitypub_follows.actor_id = id', 'inner')
|
||||
->where('activitypub_follows.target_actor_id', $actorId)
|
||||
->findAll();
|
||||
|
||||
|
@ -57,7 +57,7 @@ class FavouriteModel extends UuidModel
|
||||
]);
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes(),)
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes())
|
||||
->increment('favourites_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
@ -97,7 +97,7 @@ class FavouriteModel extends UuidModel
|
||||
$this->db->transStart();
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes(),)
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes())
|
||||
->decrement('favourites_count');
|
||||
|
||||
$this->db
|
||||
@ -125,7 +125,7 @@ class FavouriteModel extends UuidModel
|
||||
|
||||
$likeActivity = new LikeActivity();
|
||||
$likeActivity
|
||||
->set('id', base_url(route_to('activity', $actor->username, $activity->id),),)
|
||||
->set('id', base_url(route_to('activity', $actor->username, $activity->id)))
|
||||
->set('actor', $actor->uri)
|
||||
->set('object', $note->uri);
|
||||
|
||||
|
@ -83,7 +83,7 @@ class FollowModel extends Model
|
||||
'queued',
|
||||
);
|
||||
|
||||
$followActivity->set('id', base_url(route_to('activity', $actor->username, $activityId),));
|
||||
$followActivity->set('id', base_url(route_to('activity', $actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
|
@ -155,7 +155,7 @@ class NoteModel extends UuidModel
|
||||
*/
|
||||
public function getSecondsToNextUnpublishedNote(int $actorId): int | false
|
||||
{
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff',)
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff')
|
||||
->where([
|
||||
'actor_id' => $actorId,
|
||||
])
|
||||
@ -185,11 +185,11 @@ class NoteModel extends UuidModel
|
||||
if (! ($found = cache($cacheName))) {
|
||||
if (! $withBlocked) {
|
||||
$this->select('activitypub_notes.*')
|
||||
->join('activitypub_actors', 'activitypub_actors.id = activitypub_notes.actor_id', 'inner',)
|
||||
->join('activitypub_actors', 'activitypub_actors.id = activitypub_notes.actor_id', 'inner')
|
||||
->where('activitypub_actors.is_blocked', 0);
|
||||
}
|
||||
|
||||
$this->where('in_reply_to_id', $this->uuid->fromString($noteId) ->getBytes(),)
|
||||
$this->where('in_reply_to_id', $this->uuid->fromString($noteId) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC');
|
||||
$found = $this->findAll();
|
||||
@ -213,7 +213,7 @@ class NoteModel extends UuidModel
|
||||
->cachePrefix . "note#{$noteId}_reblogs";
|
||||
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->where('reblog_of_id', $this->uuid->fromString($noteId) ->getBytes(),)
|
||||
$found = $this->where('reblog_of_id', $this->uuid->fromString($noteId) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC')
|
||||
->findAll();
|
||||
@ -262,7 +262,7 @@ class NoteModel extends UuidModel
|
||||
|
||||
if (
|
||||
$messageUrls !== [] &&
|
||||
($previewCard = get_or_create_preview_card_from_url(new URI($messageUrls[0]),)) &&
|
||||
($previewCard = get_or_create_preview_card_from_url(new URI($messageUrls[0]))) &&
|
||||
! $this->addPreviewCard($newNoteId, $previewCard->id)
|
||||
) {
|
||||
$this->db->transRollback();
|
||||
@ -298,7 +298,7 @@ class NoteModel extends UuidModel
|
||||
'queued',
|
||||
);
|
||||
|
||||
$createActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId),));
|
||||
$createActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
@ -361,10 +361,10 @@ class NoteModel extends UuidModel
|
||||
->where('id', $note->actor_id)
|
||||
->decrement('notes_count');
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
// Note to remove is a reply
|
||||
model('NoteModel')
|
||||
->where('id', $this->uuid->fromString($note->in_reply_to_id) ->getBytes(),)
|
||||
->where('id', $this->uuid->fromString($note->in_reply_to_id) ->getBytes())
|
||||
->decrement('replies_count');
|
||||
|
||||
Events::trigger('on_reply_remove', $note);
|
||||
@ -372,6 +372,7 @@ class NoteModel extends UuidModel
|
||||
|
||||
// remove all note reblogs
|
||||
foreach ($note->reblogs as $reblog) {
|
||||
// FIXME: issue when actor is not local, can't get actor information
|
||||
$this->removeNote($reblog);
|
||||
}
|
||||
|
||||
@ -410,7 +411,7 @@ class NoteModel extends UuidModel
|
||||
'queued',
|
||||
);
|
||||
|
||||
$deleteActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId),));
|
||||
$deleteActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
@ -444,7 +445,7 @@ class NoteModel extends UuidModel
|
||||
$noteId = $this->addNote($reply, $createPreviewCard, $registerActivity);
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', $this->uuid->fromString($reply->in_reply_to_id) ->getBytes(),)
|
||||
->where('id', $this->uuid->fromString($reply->in_reply_to_id) ->getBytes())
|
||||
->increment('replies_count');
|
||||
|
||||
Events::trigger('on_note_reply', $reply);
|
||||
@ -491,7 +492,7 @@ class NoteModel extends UuidModel
|
||||
'queued',
|
||||
);
|
||||
|
||||
$announceActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId),));
|
||||
$announceActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
@ -517,7 +518,7 @@ class NoteModel extends UuidModel
|
||||
->decrement('notes_count');
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', $this->uuid->fromString($reblogNote->reblog_of_id) ->getBytes(),)
|
||||
->where('id', $this->uuid->fromString($reblogNote->reblog_of_id) ->getBytes())
|
||||
->decrement('reblogs_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
@ -536,7 +537,7 @@ class NoteModel extends UuidModel
|
||||
$announceActivity = new AnnounceActivity($reblogNote);
|
||||
$announceActivity->set(
|
||||
'id',
|
||||
base_url(route_to('activity', $reblogNote->actor->username, $activity->id,),),
|
||||
base_url(route_to('activity', $reblogNote->actor->username, $activity->id)),
|
||||
);
|
||||
|
||||
$undoActivity
|
||||
@ -554,10 +555,7 @@ class NoteModel extends UuidModel
|
||||
'queued',
|
||||
);
|
||||
|
||||
$undoActivity->set(
|
||||
'id',
|
||||
base_url(route_to('activity', $reblogNote->actor->username, $activityId,),),
|
||||
);
|
||||
$undoActivity->set('id', base_url(route_to('activity', $reblogNote->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
@ -607,11 +605,11 @@ class NoteModel extends UuidModel
|
||||
cache()
|
||||
->deleteMatching($cachePrefix . "note-{$hashedNoteUri}*");
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$this->clearCache($note->reply_to_note);
|
||||
}
|
||||
|
||||
if ($note->is_reblog) {
|
||||
if ($note->reblog_of_id !== null) {
|
||||
$this->clearCache($note->reblog_of_note);
|
||||
}
|
||||
}
|
||||
@ -627,7 +625,7 @@ class NoteModel extends UuidModel
|
||||
|
||||
if (! isset($data['data']['uri'])) {
|
||||
$actor = model('ActorModel')
|
||||
->getActorById($data['data']['actor_id']);
|
||||
->getActorById((int) $data['data']['actor_id']);
|
||||
|
||||
$data['data']['uri'] = base_url(route_to('note', $actor->username, $uuid4->toString()));
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class PreviewCardModel extends Model
|
||||
'activitypub_notes_preview_cards.preview_card_id = id',
|
||||
'inner',
|
||||
)
|
||||
->where('note_id', service('uuid') ->fromString($noteId) ->getBytes(),)
|
||||
->where('note_id', service('uuid') ->fromString($noteId) ->getBytes())
|
||||
->first();
|
||||
|
||||
cache()
|
||||
|
@ -35,7 +35,7 @@ class NoteObject extends ObjectType
|
||||
$this->published = $note->published_at->format(DATE_W3C);
|
||||
$this->attributedTo = $note->actor->uri;
|
||||
|
||||
if ($note->is_reply) {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$this->inReplyTo = $note->reply_to_note->uri;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class WebFinger
|
||||
}
|
||||
|
||||
if (
|
||||
! ($actor = model('ActorModel')->getActorByUsername($username, $domain,))
|
||||
! ($actor = model('ActorModel')->getActorByUsername($username, $domain))
|
||||
) {
|
||||
throw new Exception('Could not find actor');
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ class EpisodeController extends BaseController
|
||||
}
|
||||
|
||||
if (
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0],)) === null
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
($this->episode = (new EpisodeModel())->getEpisodeBySlug($params[0], $params[1],)) !== null
|
||||
($this->episode = (new EpisodeModel())->getEpisodeBySlug($params[0], $params[1])) !== null
|
||||
) {
|
||||
unset($params[1]);
|
||||
unset($params[0]);
|
||||
|
@ -64,7 +64,7 @@ if (! function_exists('generate_episode_analytics_url')) {
|
||||
$audioFileDuration <= 60
|
||||
? $audioFileSize
|
||||
: $audioFileHeaderSize +
|
||||
floor((($audioFileSize - $audioFileHeaderSize) / $audioFileDuration) * 60,),
|
||||
floor((($audioFileSize - $audioFileHeaderSize) / $audioFileDuration) * 60),
|
||||
$audioFileSize,
|
||||
$audioFileDuration,
|
||||
$publicationDate->getTimestamp(),
|
||||
|
@ -45,7 +45,7 @@ class AnalyticsPodcastByCountryModel extends Model
|
||||
public function getDataWeekly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_country_weekly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_country_weekly"))
|
||||
) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select('country_code as labels')
|
||||
@ -73,7 +73,7 @@ class AnalyticsPodcastByCountryModel extends Model
|
||||
public function getDataYearly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_country_yearly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_country_yearly"))
|
||||
) {
|
||||
$oneYearAgo = date('Y-m-d', strtotime('-1 year'));
|
||||
$found = $this->select('country_code as labels')
|
||||
|
@ -43,7 +43,7 @@ class AnalyticsPodcastByEpisodeModel extends Model
|
||||
public function getDataByDay(int $podcastId, int $episodeId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_{$episodeId}_analytics_podcast_by_episode_by_day",))
|
||||
! ($found = cache("{$podcastId}_{$episodeId}_analytics_podcast_by_episode_by_day"))
|
||||
) {
|
||||
$found = $this->select('date as labels')
|
||||
->selectSum('hits', 'values')
|
||||
@ -69,7 +69,7 @@ class AnalyticsPodcastByEpisodeModel extends Model
|
||||
public function getDataByMonth(int $podcastId, int $episodeId = null): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_{$episodeId}_analytics_podcast_by_episode_by_month",))
|
||||
! ($found = cache("{$podcastId}_{$episodeId}_analytics_podcast_by_episode_by_month"))
|
||||
) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('hits', 'values')
|
||||
|
@ -45,7 +45,7 @@ class AnalyticsPodcastByPlayerModel extends Model
|
||||
public function getDataByAppWeekly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_app_weekly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_app_weekly"))
|
||||
) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select('app as labels')
|
||||
@ -73,7 +73,7 @@ class AnalyticsPodcastByPlayerModel extends Model
|
||||
public function getDataByAppYearly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_app_yearly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_app_yearly"))
|
||||
) {
|
||||
$oneYearAgo = date('Y-m-d', strtotime('-1 year'));
|
||||
$found = $this->select('app as labels')
|
||||
@ -101,7 +101,7 @@ class AnalyticsPodcastByPlayerModel extends Model
|
||||
public function getDataByOsWeekly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_os_weekly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_os_weekly"))
|
||||
) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select('os as labels')
|
||||
@ -130,7 +130,7 @@ class AnalyticsPodcastByPlayerModel extends Model
|
||||
public function getDataByDeviceWeekly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_device_weekly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_player_by_device_weekly"))
|
||||
) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select('device as labels')
|
||||
|
@ -47,7 +47,7 @@ class AnalyticsPodcastByRegionModel extends Model
|
||||
$locale = service('request')
|
||||
->getLocale();
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_region_{$locale}",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_by_region_{$locale}"))
|
||||
) {
|
||||
$found = $this->select('country_code, region_code')
|
||||
->selectSum('hits', 'value')
|
||||
|
@ -45,7 +45,7 @@ class AnalyticsPodcastByServiceModel extends Model
|
||||
public function getDataByServiceWeekly(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_service_weekly",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcasts_by_service_weekly"))
|
||||
) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select('service as labels')
|
||||
|
@ -67,7 +67,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataByWeekday(int $podcastId): array
|
||||
{
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcasts_by_weekday"))) {
|
||||
$found = $this->select('LEFT(DAYNAME(date),3) as labels, WEEKDAY(date) as sort_labels',)
|
||||
$found = $this->select('LEFT(DAYNAME(date),3) as labels, WEEKDAY(date) as sort_labels')
|
||||
->selectSum('hits', 'values')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
@ -91,7 +91,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataBandwidthByDay(int $podcastId): array
|
||||
{
|
||||
if (! ($found = cache("{$podcastId}_analytics_podcast_by_bandwidth"))) {
|
||||
$found = $this->select('date as labels, round(bandwidth / 1048576, 1) as `values`',)
|
||||
$found = $this->select('date as labels, round(bandwidth / 1048576, 1) as `values`')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
'date >' => date('Y-m-d', strtotime('-60 days')),
|
||||
@ -136,7 +136,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataUniqueListenersByDay(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_day",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_day"))
|
||||
) {
|
||||
$found = $this->select('date as labels, unique_listeners as values')
|
||||
->where([
|
||||
@ -160,7 +160,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataUniqueListenersByMonth(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_month",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_unique_listeners_by_month"))
|
||||
) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('unique_listeners', 'values')
|
||||
@ -185,7 +185,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataTotalListeningTimeByDay(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_day",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_day"))
|
||||
) {
|
||||
$found = $this->select('date as labels')
|
||||
->selectSum('duration', 'values')
|
||||
@ -211,7 +211,7 @@ class AnalyticsPodcastModel extends Model
|
||||
public function getDataTotalListeningTimeByMonth(int $podcastId): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_month",))
|
||||
! ($found = cache("{$podcastId}_analytics_podcast_listening_time_by_month"))
|
||||
) {
|
||||
$found = $this->select('DATE_FORMAT(date,"%Y-%m-01") as labels')
|
||||
->selectSum('duration', 'values')
|
||||
|
@ -46,7 +46,7 @@ class AnalyticsWebsiteByEntryPageModel extends Model
|
||||
{
|
||||
if (! ($found = cache("{$podcastId}_analytics_website_by_entry_page"))) {
|
||||
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
|
||||
$found = $this->select("IF(entry_page_url='/','/',SUBSTRING_INDEX(entry_page_url,'/',-1)) as labels",)
|
||||
$found = $this->select("IF(entry_page_url='/','/',SUBSTRING_INDEX(entry_page_url,'/',-1)) as labels")
|
||||
->selectSum('hits', 'values')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
|
@ -54,7 +54,7 @@ class Router extends CodeIgniterRouter
|
||||
if (str_contains($key, '{locale}')) {
|
||||
$localeSegment = array_search(
|
||||
'{locale}',
|
||||
preg_split('~[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+~m', $key,),
|
||||
preg_split('~[\/]*((^[a-zA-Z0-9])|\(([^()]*)\))*[\/]+~m', $key),
|
||||
true,
|
||||
);
|
||||
|
||||
@ -104,7 +104,7 @@ class Router extends CodeIgniterRouter
|
||||
// check if the alternate-content has been requested in the accept
|
||||
// header and overwrite the $val with the matching controller method
|
||||
if (
|
||||
array_key_exists('alternate-content', $this->matchedRouteOptions,) &&
|
||||
array_key_exists('alternate-content', $this->matchedRouteOptions) &&
|
||||
is_array($this->matchedRouteOptions['alternate-content'])
|
||||
) {
|
||||
$request = Services::request();
|
||||
@ -119,7 +119,7 @@ class Router extends CodeIgniterRouter
|
||||
$expectedContentType = $parsedHeader[0];
|
||||
foreach ($supported as $available) {
|
||||
if (
|
||||
$negotiate->callMatch($expectedContentType, $available, true,)
|
||||
$negotiate->callMatch($expectedContentType, $available, true)
|
||||
) {
|
||||
if (
|
||||
array_key_exists(
|
||||
|
@ -130,7 +130,7 @@ class CategoryModel extends Model
|
||||
$cacheName = "podcast#{$podcastId}_categories";
|
||||
if (! ($categories = cache($cacheName))) {
|
||||
$categories = $this->select('categories.*')
|
||||
->join('podcasts_categories', 'podcasts_categories.category_id = categories.id',)
|
||||
->join('podcasts_categories', 'podcasts_categories.category_id = categories.id')
|
||||
->where('podcasts_categories.podcast_id', $podcastId)
|
||||
->findAll();
|
||||
|
||||
|
@ -265,7 +265,7 @@ class EpisodeModel extends Model
|
||||
*/
|
||||
public function getSecondsToNextUnpublishedEpisode(int $podcastId): int | false
|
||||
{
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff',)
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
])
|
||||
|
@ -423,7 +423,7 @@ class PersonModel extends Model
|
||||
*/
|
||||
protected function clearCache(array $data): array
|
||||
{
|
||||
$personId = is_array($data['id']) ? $data['id']['id'] : $data['id'];
|
||||
$personId = is_array($data['id']) ? $data['id'][0] : $data['id'];
|
||||
|
||||
cache()
|
||||
->delete('person_options');
|
||||
|
@ -99,7 +99,7 @@ class PlatformModel extends Model
|
||||
public function getPlatformsWithLinks(int $podcastId, string $platformType): array
|
||||
{
|
||||
if (
|
||||
! ($found = cache("podcast#{$podcastId}_platforms_{$platformType}_withLinks",))
|
||||
! ($found = cache("podcast#{$podcastId}_platforms_{$platformType}_withLinks"))
|
||||
) {
|
||||
$found = $this->select(
|
||||
'platforms.*, podcasts_platforms.link_url, podcasts_platforms.link_content, podcasts_platforms.is_visible, podcasts_platforms.is_on_embeddable_player',
|
||||
@ -129,7 +129,7 @@ class PlatformModel extends Model
|
||||
$found = $this->select(
|
||||
'platforms.*, podcasts_platforms.link_url, podcasts_platforms.link_content, podcasts_platforms.is_visible, podcasts_platforms.is_on_embeddable_player',
|
||||
)
|
||||
->join('podcasts_platforms', 'podcasts_platforms.platform_slug = platforms.slug',)
|
||||
->join('podcasts_platforms', 'podcasts_platforms.platform_slug = platforms.slug')
|
||||
->where('podcasts_platforms.podcast_id', $podcastId)
|
||||
->where('platforms.type', $platformType)
|
||||
->findAll();
|
||||
|
@ -175,7 +175,7 @@ class PodcastModel extends Model
|
||||
$cacheName = "user{$userId}_podcasts";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->select('podcasts.*')
|
||||
->join('podcasts_users', 'podcasts_users.podcast_id = podcasts.id',)
|
||||
->join('podcasts_users', 'podcasts_users.podcast_id = podcasts.id')
|
||||
->where('podcasts_users.user_id', $userId)
|
||||
->findAll();
|
||||
|
||||
@ -268,7 +268,7 @@ class PodcastModel extends Model
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$episodeModel = new EpisodeModel();
|
||||
$found = $episodeModel
|
||||
->select('YEAR(published_at) as year, count(*) as number_of_episodes',)
|
||||
->select('YEAR(published_at) as year, count(*) as number_of_episodes')
|
||||
->where([
|
||||
'podcast_id' => $podcastId,
|
||||
'season_number' => null,
|
||||
|
@ -29,7 +29,7 @@ class UserModel extends MythAuthUserModel
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->select('users.*, auth_groups.name as podcast_role')
|
||||
->join('podcasts_users', 'podcasts_users.user_id = users.id')
|
||||
->join('auth_groups', 'auth_groups.id = podcasts_users.group_id',)
|
||||
->join('auth_groups', 'auth_groups.id = podcasts_users.group_id')
|
||||
->where('podcasts_users.podcast_id', $podcastId)
|
||||
->findAll();
|
||||
|
||||
@ -42,7 +42,7 @@ class UserModel extends MythAuthUserModel
|
||||
|
||||
public function getPodcastContributor(int $userId, int $podcastId): ?User
|
||||
{
|
||||
return $this->select('users.*, podcasts_users.podcast_id as podcast_id, auth_groups.name as podcast_role',)
|
||||
return $this->select('users.*, podcasts_users.podcast_id as podcast_id, auth_groups.name as podcast_role')
|
||||
->join('podcasts_users', 'podcasts_users.user_id = users.id')
|
||||
->join('auth_groups', 'auth_groups.id = podcasts_users.group_id')
|
||||
->where([
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
<section class="max-w-2xl px-6 py-8 mx-auto space-y-8">
|
||||
<?php foreach ($notes as $note): ?>
|
||||
<?php if ($note->is_reblog): ?>
|
||||
<?php if ($note->reblog_of_id !== null): ?>
|
||||
<?= view('podcast/_partials/reblog', [
|
||||
'note' => $note->reblog_of_note,
|
||||
]) ?>
|
||||
|
@ -85,7 +85,7 @@
|
||||
|
||||
<div class="space-y-8">
|
||||
<?php foreach ($notes as $note): ?>
|
||||
<?php if ($note->is_reblog): ?>
|
||||
<?php if ($note->reblog_of_id !== null): ?>
|
||||
<?= view('podcast/_partials/reblog_authenticated', [
|
||||
'note' => $note->reblog_of_note,
|
||||
]) ?>
|
||||
|
Loading…
Reference in New Issue
Block a user