refactor: rename all occurences of notes to statuses
This commit is contained in:
parent
ddeabf5665
commit
134a071add
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Config;
|
||||
|
||||
use App\Entities\Actor;
|
||||
use App\Entities\Note;
|
||||
use App\Entities\Status;
|
||||
use App\Entities\User;
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
|
@ -120,82 +120,82 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void {
|
|||
});
|
||||
|
||||
/**
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
Events::on('on_note_add', function ($note): void {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$note = $note->reply_to_note;
|
||||
Events::on('on_status_add', function ($status): void {
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
$status = $status->reply_to_status;
|
||||
}
|
||||
|
||||
if ($note->episode_id) {
|
||||
if ($status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $note->episode_id)
|
||||
->increment('notes_total');
|
||||
->where('id', $status->episode_id)
|
||||
->increment('statuses_total');
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
// Removing all of the podcast pages is a bit overkill, but works to avoid caching bugs
|
||||
// same for other events below
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
Events::on('on_note_remove', function ($note): void {
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
Events::trigger('on_note_remove', $note->reply_to_note);
|
||||
Events::on('on_status_remove', function ($status): void {
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
Events::trigger('on_status_remove', $status->reply_to_status);
|
||||
}
|
||||
|
||||
if ($episodeId = $note->episode_id) {
|
||||
if ($episodeId = $status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->decrement('notes_total', 1 + $note->reblogs_count);
|
||||
->decrement('statuses_total', 1 + $status->reblogs_count);
|
||||
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->decrement('reblogs_total', $note->reblogs_count);
|
||||
->decrement('reblogs_total', $status->reblogs_count);
|
||||
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->decrement('favourites_total', $note->favourites_count);
|
||||
->decrement('favourites_total', $status->favourites_count);
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Actor $actor
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
Events::on('on_note_reblog', function ($actor, $note): void {
|
||||
if ($episodeId = $note->episode_id) {
|
||||
Events::on('on_status_reblog', function ($actor, $status): void {
|
||||
if ($episodeId = $status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->increment('reblogs_total');
|
||||
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->increment('notes_total');
|
||||
->increment('statuses_total');
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
if ($actor->is_podcast) {
|
||||
|
@ -205,111 +205,111 @@ Events::on('on_note_reblog', function ($actor, $note): void {
|
|||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_status#{$status->in_reply_to_id}");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Note $reblogNote
|
||||
* @param Status $reblogStatus
|
||||
*/
|
||||
Events::on('on_note_undo_reblog', function ($reblogNote): void {
|
||||
$note = $reblogNote->reblog_of_note;
|
||||
if ($episodeId = $note->episode_id) {
|
||||
Events::on('on_status_undo_reblog', function ($reblogStatus): void {
|
||||
$status = $reblogStatus->reblog_of_status;
|
||||
if ($episodeId = $status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->decrement('reblogs_total');
|
||||
|
||||
model('EpisodeModel')
|
||||
->where('id', $episodeId)
|
||||
->decrement('notes_total');
|
||||
->decrement('statuses_total');
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_note#{$reblogNote->id}*");
|
||||
->deleteMatching("page_status#{$reblogStatus->id}*");
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}");
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_status#{$status->in_reply_to_id}");
|
||||
}
|
||||
|
||||
if ($reblogNote->actor->is_podcast) {
|
||||
if ($reblogStatus->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$reblogNote->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$reblogStatus->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$reblogNote->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$reblogStatus->actor->podcast->id}*");
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Note $reply
|
||||
* @param Status $reply
|
||||
*/
|
||||
Events::on('on_note_reply', function ($reply): void {
|
||||
$note = $reply->reply_to_note;
|
||||
Events::on('on_status_reply', function ($reply): void {
|
||||
$status = $reply->reply_to_status;
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Note $reply
|
||||
* @param Status $reply
|
||||
*/
|
||||
Events::on('on_reply_remove', function ($reply): void {
|
||||
$note = $reply->reply_to_note;
|
||||
$status = $reply->reply_to_status;
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_note#{$reply->id}*");
|
||||
->deleteMatching("page_status#{$reply->id}*");
|
||||
});
|
||||
|
||||
/**
|
||||
* @param Actor $actor
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
Events::on('on_note_favourite', function ($actor, $note): void {
|
||||
if ($note->episode_id) {
|
||||
Events::on('on_status_favourite', function ($actor, $status): void {
|
||||
if ($status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $note->episode_id)
|
||||
->where('id', $status->episode_id)
|
||||
->increment('favourites_total');
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_status#{$status->in_reply_to_id}*");
|
||||
}
|
||||
|
||||
if ($actor->is_podcast) {
|
||||
|
@ -321,27 +321,27 @@ Events::on('on_note_favourite', function ($actor, $note): void {
|
|||
|
||||
/**
|
||||
* @param Actor $actor
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
Events::on('on_note_undo_favourite', function ($actor, $note): void {
|
||||
if ($note->episode_id) {
|
||||
Events::on('on_status_undo_favourite', function ($actor, $status): void {
|
||||
if ($status->episode_id) {
|
||||
model('EpisodeModel')
|
||||
->where('id', $note->episode_id)
|
||||
->where('id', $status->episode_id)
|
||||
->decrement('favourites_total');
|
||||
}
|
||||
|
||||
if ($note->actor->is_podcast) {
|
||||
if ($status->actor->is_podcast) {
|
||||
cache()
|
||||
->deleteMatching("podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("podcast#{$status->actor->podcast->id}*");
|
||||
cache()
|
||||
->deleteMatching("page_podcast#{$note->actor->podcast->id}*");
|
||||
->deleteMatching("page_podcast#{$status->actor->podcast->id}*");
|
||||
}
|
||||
|
||||
cache()
|
||||
->deleteMatching("page_note#{$note->id}*");
|
||||
->deleteMatching("page_status#{$status->id}*");
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_note#{$note->in_reply_to_id}*");
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
cache()->deleteMatching("page_status#{$status->in_reply_to_id}*");
|
||||
}
|
||||
|
||||
if ($actor->is_podcast) {
|
||||
|
@ -356,7 +356,7 @@ Events::on('on_block_actor', function (int $actorId): void {
|
|||
cache()
|
||||
->deleteMatching('podcast*');
|
||||
cache()
|
||||
->deleteMatching('page_note*');
|
||||
->deleteMatching('page_status*');
|
||||
});
|
||||
|
||||
Events::on('on_unblock_actor', function (int $actorId): void {
|
||||
|
@ -364,7 +364,7 @@ Events::on('on_unblock_actor', function (int $actorId): void {
|
|||
cache()
|
||||
->deleteMatching('podcast*');
|
||||
cache()
|
||||
->deleteMatching('page_note*');
|
||||
->deleteMatching('page_status*');
|
||||
});
|
||||
|
||||
Events::on('on_block_domain', function (string $domainName): void {
|
||||
|
@ -372,7 +372,7 @@ Events::on('on_block_domain', function (string $domainName): void {
|
|||
cache()
|
||||
->deleteMatching('podcast*');
|
||||
cache()
|
||||
->deleteMatching('page_note*');
|
||||
->deleteMatching('page_status*');
|
||||
});
|
||||
|
||||
Events::on('on_unblock_domain', function (string $domainName): void {
|
||||
|
@ -380,5 +380,5 @@ Events::on('on_unblock_domain', function (string $domainName): void {
|
|||
cache()
|
||||
->deleteMatching('podcast*');
|
||||
cache()
|
||||
->deleteMatching('page_note*');
|
||||
->deleteMatching('page_status*');
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ $routes->addPlaceholder('podcastName', '[a-zA-Z0-9\_]{1,32}');
|
|||
$routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,191}');
|
||||
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
|
||||
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
|
||||
$routes->addPlaceholder('noteAction', '\bfavourite|\breblog|\breply');
|
||||
$routes->addPlaceholder('statusAction', '\bfavourite|\breblog|\breply');
|
||||
$routes->addPlaceholder('embeddablePlayerTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent');
|
||||
$routes->addPlaceholder(
|
||||
'uuid',
|
||||
|
@ -746,71 +746,71 @@ $routes->post('interact-as-actor', 'AuthController::attemptInteractAsActor', [
|
|||
* Overwriting ActivityPub routes file
|
||||
*/
|
||||
$routes->group('@(:podcastName)', function ($routes): void {
|
||||
$routes->post('notes/new', 'NoteController::attemptCreate/$1', [
|
||||
'as' => 'note-attempt-create',
|
||||
$routes->post('statuses/new', 'StatusController::attemptCreate/$1', [
|
||||
'as' => 'status-attempt-create',
|
||||
'filter' => 'permission:podcast-manage_publications',
|
||||
]);
|
||||
// Note
|
||||
$routes->group('notes/(:uuid)', function ($routes): void {
|
||||
$routes->get('/', 'NoteController::view/$1/$2', [
|
||||
'as' => 'note',
|
||||
// Status
|
||||
$routes->group('statuses/(:uuid)', function ($routes): void {
|
||||
$routes->get('/', 'StatusController::view/$1/$2', [
|
||||
'as' => 'status',
|
||||
'alternate-content' => [
|
||||
'application/activity+json' => [
|
||||
'namespace' => 'ActivityPub\Controllers',
|
||||
'controller-method' => 'NoteController/$2',
|
||||
'controller-method' => 'StatusController/$2',
|
||||
],
|
||||
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
||||
'namespace' => 'ActivityPub\Controllers',
|
||||
'controller-method' => 'NoteController/$2',
|
||||
'controller-method' => 'StatusController/$2',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$routes->get('replies', 'NoteController/$1/$2', [
|
||||
'as' => 'note-replies',
|
||||
$routes->get('replies', 'StatusController/$1/$2', [
|
||||
'as' => 'status-replies',
|
||||
'alternate-content' => [
|
||||
'application/activity+json' => [
|
||||
'namespace' => 'ActivityPub\Controllers',
|
||||
'controller-method' => 'NoteController::replies/$2',
|
||||
'controller-method' => 'StatusController::replies/$2',
|
||||
],
|
||||
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
||||
'namespace' => 'ActivityPub\Controllers',
|
||||
'controller-method' => 'NoteController::replies/$2',
|
||||
'controller-method' => 'StatusController::replies/$2',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Actions
|
||||
$routes->post('action', 'NoteController::attemptAction/$1/$2', [
|
||||
'as' => 'note-attempt-action',
|
||||
$routes->post('action', 'StatusController::attemptAction/$1/$2', [
|
||||
'as' => 'status-attempt-action',
|
||||
'filter' => 'permission:podcast-interact_as',
|
||||
]);
|
||||
|
||||
$routes->post(
|
||||
'block-actor',
|
||||
'NoteController::attemptBlockActor/$1/$2',
|
||||
'StatusController::attemptBlockActor/$1/$2',
|
||||
[
|
||||
'as' => 'note-attempt-block-actor',
|
||||
'as' => 'status-attempt-block-actor',
|
||||
'filter' => 'permission:fediverse-block_actors',
|
||||
],
|
||||
);
|
||||
$routes->post(
|
||||
'block-domain',
|
||||
'NoteController::attemptBlockDomain/$1/$2',
|
||||
'StatusController::attemptBlockDomain/$1/$2',
|
||||
[
|
||||
'as' => 'note-attempt-block-domain',
|
||||
'as' => 'status-attempt-block-domain',
|
||||
'filter' => 'permission:fediverse-block_domains',
|
||||
],
|
||||
);
|
||||
$routes->post('delete', 'NoteController::attemptDelete/$1/$2', [
|
||||
'as' => 'note-attempt-delete',
|
||||
$routes->post('delete', 'StatusController::attemptDelete/$1/$2', [
|
||||
'as' => 'status-attempt-delete',
|
||||
'filter' => 'permission:podcast-manage_publications',
|
||||
]);
|
||||
|
||||
$routes->get(
|
||||
'remote/(:noteAction)',
|
||||
'NoteController::remoteAction/$1/$2/$3',
|
||||
'remote/(:statusAction)',
|
||||
'StatusController::remoteAction/$1/$2/$3',
|
||||
[
|
||||
'as' => 'note-remote-action',
|
||||
'as' => 'status-remote-action',
|
||||
],
|
||||
);
|
||||
});
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace App\Controllers\Admin;
|
|||
use App\Entities\Episode;
|
||||
use App\Entities\Image;
|
||||
use App\Entities\Location;
|
||||
use App\Entities\Note;
|
||||
use App\Entities\Podcast;
|
||||
use App\Entities\Status;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\NoteModel;
|
||||
use App\Models\PodcastModel;
|
||||
use App\Models\SoundbiteModel;
|
||||
use App\Models\StatusModel;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
@ -426,7 +426,7 @@ class EpisodeController extends BaseController
|
|||
$db = db_connect();
|
||||
$db->transStart();
|
||||
|
||||
$newNote = new Note([
|
||||
$newStatus = new Status([
|
||||
'actor_id' => $this->podcast->actor_id,
|
||||
'episode_id' => $this->episode->id,
|
||||
'message' => $this->request->getPost('message'),
|
||||
|
@ -453,15 +453,15 @@ class EpisodeController extends BaseController
|
|||
$this->episode->published_at = Time::now();
|
||||
}
|
||||
|
||||
$newNote->published_at = $this->episode->published_at;
|
||||
$newStatus->published_at = $this->episode->published_at;
|
||||
|
||||
$noteModel = new NoteModel();
|
||||
if (! $noteModel->addNote($newNote)) {
|
||||
$statusModel = new StatusModel();
|
||||
if (! $statusModel->addStatus($newStatus)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $noteModel->errors());
|
||||
->with('errors', $statusModel->errors());
|
||||
}
|
||||
|
||||
$episodeModel = new EpisodeModel();
|
||||
|
@ -486,7 +486,7 @@ class EpisodeController extends BaseController
|
|||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'episode' => $this->episode,
|
||||
'note' => (new NoteModel())
|
||||
'status' => (new StatusModel())
|
||||
->where([
|
||||
'actor_id' => $this->podcast->actor_id,
|
||||
'episode_id' => $this->episode->id,
|
||||
|
@ -506,7 +506,7 @@ class EpisodeController extends BaseController
|
|||
public function attemptPublishEdit(): RedirectResponse
|
||||
{
|
||||
$rules = [
|
||||
'note_id' => 'required',
|
||||
'status_id' => 'required',
|
||||
'publication_method' => 'required',
|
||||
'scheduled_publication_date' =>
|
||||
'valid_date[Y-m-d H:i]|permit_empty',
|
||||
|
@ -542,19 +542,19 @@ class EpisodeController extends BaseController
|
|||
$this->episode->published_at = Time::now();
|
||||
}
|
||||
|
||||
$note = (new NoteModel())->getNoteById($this->request->getPost('note_id'));
|
||||
$status = (new StatusModel())->getStatusById($this->request->getPost('status_id'));
|
||||
|
||||
if ($note !== null) {
|
||||
$note->message = $this->request->getPost('message');
|
||||
$note->published_at = $this->episode->published_at;
|
||||
if ($status !== null) {
|
||||
$status->message = $this->request->getPost('message');
|
||||
$status->published_at = $this->episode->published_at;
|
||||
|
||||
$noteModel = new NoteModel();
|
||||
if (! $noteModel->editNote($note)) {
|
||||
$statusModel = new StatusModel();
|
||||
if (! $statusModel->editStatus($status)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $noteModel->errors());
|
||||
->with('errors', $statusModel->errors());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,13 +609,13 @@ class EpisodeController extends BaseController
|
|||
|
||||
$db->transStart();
|
||||
|
||||
$allNotesLinkedToEpisode = (new NoteModel())
|
||||
$allStatusesLinkedToEpisode = (new StatusModel())
|
||||
->where([
|
||||
'episode_id' => $this->episode->id,
|
||||
])
|
||||
->findAll();
|
||||
foreach ($allNotesLinkedToEpisode as $note) {
|
||||
(new NoteModel())->removeNote($note);
|
||||
foreach ($allStatusesLinkedToEpisode as $status) {
|
||||
(new StatusModel())->removeStatus($status);
|
||||
}
|
||||
|
||||
// set episode published_at to null to unpublish
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace App\Controllers;
|
|||
use Analytics\AnalyticsTrait;
|
||||
use App\Entities\Podcast;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\NoteModel;
|
||||
use App\Models\PodcastModel;
|
||||
use App\Models\StatusModel;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
|
||||
class PodcastController extends BaseController
|
||||
|
@ -64,7 +64,7 @@ class PodcastController extends BaseController
|
|||
if (! ($cachedView = cache($cacheName))) {
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'notes' => (new NoteModel())->getActorPublishedNotes($this->podcast->actor_id),
|
||||
'statuses' => (new StatusModel())->getActorPublishedStatuses($this->podcast->actor_id),
|
||||
];
|
||||
|
||||
// if user is logged in then send to the authenticated activity view
|
||||
|
|
|
@ -10,21 +10,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use ActivityPub\Controllers\NoteController as ActivityPubNoteController;
|
||||
use ActivityPub\Entities\Note as ActivityPubNote;
|
||||
use ActivityPub\Controllers\StatusController as ActivityPubStatusController;
|
||||
use ActivityPub\Entities\Status as ActivityPubStatus;
|
||||
use Analytics\AnalyticsTrait;
|
||||
use App\Entities\Actor;
|
||||
use App\Entities\Note as CastopodNote;
|
||||
use App\Entities\Podcast;
|
||||
use App\Entities\Status as CastopodStatus;
|
||||
use App\Models\EpisodeModel;
|
||||
use App\Models\NoteModel;
|
||||
use App\Models\PodcastModel;
|
||||
use App\Models\StatusModel;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\URI;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class NoteController extends ActivityPubNoteController
|
||||
class StatusController extends ActivityPubStatusController
|
||||
{
|
||||
use AnalyticsTrait;
|
||||
|
||||
|
@ -50,9 +50,9 @@ class NoteController extends ActivityPubNoteController
|
|||
|
||||
if (
|
||||
count($params) > 1 &&
|
||||
($note = (new NoteModel())->getNoteById($params[1])) !== null
|
||||
($status = (new StatusModel())->getStatusById($params[1])) !== null
|
||||
) {
|
||||
$this->note = $note;
|
||||
$this->status = $status;
|
||||
|
||||
unset($params[0]);
|
||||
unset($params[1]);
|
||||
|
@ -72,7 +72,7 @@ class NoteController extends ActivityPubNoteController
|
|||
'_',
|
||||
array_filter([
|
||||
'page',
|
||||
"note#{$this->note->id}",
|
||||
"status#{$this->status->id}",
|
||||
service('request')
|
||||
->getLocale(),
|
||||
can_user_interact() ? '_authenticated' : null,
|
||||
|
@ -83,15 +83,15 @@ class NoteController extends ActivityPubNoteController
|
|||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'actor' => $this->actor,
|
||||
'note' => $this->note,
|
||||
'status' => $this->status,
|
||||
];
|
||||
|
||||
// if user is logged in then send to the authenticated activity view
|
||||
if (can_user_interact()) {
|
||||
helper('form');
|
||||
return view('podcast/note_authenticated', $data);
|
||||
return view('podcast/status_authenticated', $data);
|
||||
}
|
||||
return view('podcast/note', $data, [
|
||||
return view('podcast/status', $data, [
|
||||
'cache' => DECADE,
|
||||
'cache_name' => $cacheName,
|
||||
]);
|
||||
|
@ -116,7 +116,7 @@ class NoteController extends ActivityPubNoteController
|
|||
|
||||
$message = $this->request->getPost('message');
|
||||
|
||||
$newNote = new CastopodNote([
|
||||
$newStatus = new CastopodStatus([
|
||||
'actor_id' => interact_as_actor_id(),
|
||||
'published_at' => Time::now(),
|
||||
'created_by' => user_id(),
|
||||
|
@ -129,23 +129,23 @@ class NoteController extends ActivityPubNoteController
|
|||
($params = extract_params_from_episode_uri(new URI($episodeUri))) &&
|
||||
($episode = (new EpisodeModel())->getEpisodeBySlug($params['podcastName'], $params['episodeSlug']))
|
||||
) {
|
||||
$newNote->episode_id = $episode->id;
|
||||
$newStatus->episode_id = $episode->id;
|
||||
}
|
||||
|
||||
$newNote->message = $message;
|
||||
$newStatus->message = $message;
|
||||
|
||||
$noteModel = new NoteModel();
|
||||
$statusModel = new StatusModel();
|
||||
if (
|
||||
! $noteModel
|
||||
->addNote($newNote, ! (bool) $newNote->episode_id, true)
|
||||
! $statusModel
|
||||
->addStatus($newStatus, ! (bool) $newStatus->episode_id, true)
|
||||
) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $noteModel->errors());
|
||||
->with('errors', $statusModel->errors());
|
||||
}
|
||||
|
||||
// Note has been successfully created
|
||||
// Status has been successfully created
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
@ -162,36 +162,36 @@ class NoteController extends ActivityPubNoteController
|
|||
->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$newNote = new ActivityPubNote([
|
||||
$newStatus = new ActivityPubStatus([
|
||||
'actor_id' => interact_as_actor_id(),
|
||||
'in_reply_to_id' => $this->note->id,
|
||||
'in_reply_to_id' => $this->status->id,
|
||||
'message' => $this->request->getPost('message'),
|
||||
'published_at' => Time::now(),
|
||||
'created_by' => user_id(),
|
||||
]);
|
||||
|
||||
$noteModel = new NoteModel();
|
||||
if (! $noteModel->addReply($newNote)) {
|
||||
$statusModel = new StatusModel();
|
||||
if (! $statusModel->addReply($newStatus)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $noteModel->errors());
|
||||
->with('errors', $statusModel->errors());
|
||||
}
|
||||
|
||||
// Reply note without preview card has been successfully created
|
||||
// Reply status without preview card has been successfully created
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function attemptFavourite(): RedirectResponse
|
||||
{
|
||||
model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->note);
|
||||
model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->status);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function attemptReblog(): RedirectResponse
|
||||
{
|
||||
(new NoteModel())->toggleReblog(interact_as_actor(), $this->note);
|
||||
(new StatusModel())->toggleReblog(interact_as_actor(), $this->status);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
@ -230,20 +230,20 @@ class NoteController extends ActivityPubNoteController
|
|||
|
||||
$cacheName = implode(
|
||||
'_',
|
||||
array_filter(['page', "note#{$this->note->id}", "remote_{$action}", service('request') ->getLocale()]),
|
||||
array_filter(['page', "status#{$this->status->id}", "remote_{$action}", service('request') ->getLocale()]),
|
||||
);
|
||||
|
||||
if (! ($cachedView = cache($cacheName))) {
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'actor' => $this->actor,
|
||||
'note' => $this->note,
|
||||
'status' => $this->status,
|
||||
'action' => $action,
|
||||
];
|
||||
|
||||
helper('form');
|
||||
|
||||
return view('podcast/note_remote_action', $data, [
|
||||
return view('podcast/status_remote_action', $data, [
|
||||
'cache' => DECADE,
|
||||
'cache_name' => $cacheName,
|
||||
]);
|
|
@ -157,7 +157,7 @@ class AddEpisodes extends Migration
|
|||
'unsigned' => true,
|
||||
'default' => 0,
|
||||
],
|
||||
'notes_total' => [
|
||||
'statuses_total' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'default' => 0,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Class AddEpisodeIdToNotes Adds episode_id field to activitypub_notes table in database
|
||||
* Class AddEpisodeIdToStatuses Adds episode_id field to activitypub_statuses table in database
|
||||
*
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -14,23 +14,23 @@ namespace App\Database\Migrations;
|
|||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddEpisodeIdToNotes extends Migration
|
||||
class AddEpisodeIdToStatuses extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$prefix = $this->db->getPrefix();
|
||||
|
||||
$createQuery = <<<CODE_SAMPLE
|
||||
ALTER TABLE {$prefix}activitypub_notes
|
||||
ALTER TABLE {$prefix}activitypub_statuses
|
||||
ADD COLUMN `episode_id` INT UNSIGNED NULL AFTER `replies_count`,
|
||||
ADD FOREIGN KEY {$prefix}activitypub_notes_episode_id_foreign(episode_id) REFERENCES {$prefix}episodes(id) ON DELETE CASCADE;
|
||||
ADD FOREIGN KEY {$prefix}activitypub_statuses_episode_id_foreign(episode_id) REFERENCES {$prefix}episodes(id) ON DELETE CASCADE;
|
||||
CODE_SAMPLE;
|
||||
$this->db->query($createQuery);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_episode_id_foreign');
|
||||
$this->forge->dropColumn('activitypub_notes', 'episode_id');
|
||||
$this->forge->dropForeignKey('activitypub_statuses', 'activitypub_statuses_episode_id_foreign');
|
||||
$this->forge->dropColumn('activitypub_statuses', 'episode_id');
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Class AddCreatedByToNotes Adds created_by field to activitypub_notes table in database
|
||||
* Class AddCreatedByToStatuses Adds created_by field to activitypub_statuses table in database
|
||||
*
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -14,23 +14,23 @@ namespace App\Database\Migrations;
|
|||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddCreatedByToNotes extends Migration
|
||||
class AddCreatedByToStatuses extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$prefix = $this->db->getPrefix();
|
||||
|
||||
$createQuery = <<<CODE_SAMPLE
|
||||
ALTER TABLE {$prefix}activitypub_notes
|
||||
ALTER TABLE {$prefix}activitypub_statuses
|
||||
ADD COLUMN `created_by` INT UNSIGNED AFTER `episode_id`,
|
||||
ADD FOREIGN KEY {$prefix}activitypub_notes_created_by_foreign(created_by) REFERENCES {$prefix}users(id) ON DELETE CASCADE;
|
||||
ADD FOREIGN KEY {$prefix}activitypub_statuses_created_by_foreign(created_by) REFERENCES {$prefix}users(id) ON DELETE CASCADE;
|
||||
CODE_SAMPLE;
|
||||
$this->db->query($createQuery);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_created_by_foreign');
|
||||
$this->forge->dropColumn('activitypub_notes', 'created_by');
|
||||
$this->forge->dropForeignKey('activitypub_statuses', 'activitypub_statuses_created_by_foreign');
|
||||
$this->forge->dropColumn('activitypub_statuses', 'created_by');
|
||||
}
|
||||
}
|
|
@ -162,13 +162,13 @@ class AuthSeeder extends Seeder
|
|||
[
|
||||
'name' => 'manage_publications',
|
||||
'description' =>
|
||||
'Publish / unpublish episodes & notes of a podcast',
|
||||
'Publish / unpublish episodes & statuses of a podcast',
|
||||
'has_permission' => ['podcast_admin'],
|
||||
],
|
||||
[
|
||||
'name' => 'interact_as',
|
||||
'description' =>
|
||||
'Interact as the podcast to favourite / share or reply to notes.',
|
||||
'Interact as the podcast to favourite / share or reply to statuses.',
|
||||
'has_permission' => ['podcast_admin'],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -11,10 +11,10 @@ declare(strict_types=1);
|
|||
namespace App\Entities;
|
||||
|
||||
use App\Libraries\SimpleRSSElement;
|
||||
use App\Models\NoteModel;
|
||||
use App\Models\PersonModel;
|
||||
use App\Models\PodcastModel;
|
||||
use App\Models\SoundbiteModel;
|
||||
use App\Models\StatusModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
use CodeIgniter\Files\File;
|
||||
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||
|
@ -67,7 +67,7 @@ use RuntimeException;
|
|||
* @property string $custom_rss_string
|
||||
* @property int $favourites_total
|
||||
* @property int $reblogs_total
|
||||
* @property int $notes_total
|
||||
* @property int $statuses_total
|
||||
* @property int $created_by
|
||||
* @property int $updated_by
|
||||
* @property string $publication_status;
|
||||
|
@ -117,9 +117,9 @@ class Episode extends Entity
|
|||
protected ?array $soundbites = null;
|
||||
|
||||
/**
|
||||
* @var Note[]|null
|
||||
* @var Status[]|null
|
||||
*/
|
||||
protected ?array $notes = null;
|
||||
protected ?array $statuses = null;
|
||||
|
||||
protected ?Location $location = null;
|
||||
|
||||
|
@ -165,7 +165,7 @@ class Episode extends Entity
|
|||
'custom_rss' => '?json-array',
|
||||
'favourites_total' => 'integer',
|
||||
'reblogs_total' => 'integer',
|
||||
'notes_total' => 'integer',
|
||||
'statuses_total' => 'integer',
|
||||
'created_by' => 'integer',
|
||||
'updated_by' => 'integer',
|
||||
];
|
||||
|
@ -382,19 +382,19 @@ class Episode extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getNotes(): array
|
||||
public function getStatuses(): array
|
||||
{
|
||||
if ($this->id === null) {
|
||||
throw new RuntimeException('Episode must be created before getting soundbites.');
|
||||
}
|
||||
|
||||
if ($this->notes === null) {
|
||||
$this->notes = (new NoteModel())->getEpisodeNotes($this->id);
|
||||
if ($this->statuses === null) {
|
||||
$this->statuses = (new StatusModel())->getEpisodeStatuses($this->id);
|
||||
}
|
||||
|
||||
return $this->notes;
|
||||
return $this->statuses;
|
||||
}
|
||||
|
||||
public function getLink(): string
|
||||
|
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entities;
|
||||
|
||||
use ActivityPub\Entities\Note as ActivityPubNote;
|
||||
use ActivityPub\Entities\Status as ActivityPubStatus;
|
||||
use App\Models\EpisodeModel;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -18,7 +18,7 @@ use RuntimeException;
|
|||
* @property int|null $episode_id
|
||||
* @property Episode|null $episode
|
||||
*/
|
||||
class Note extends ActivityPubNote
|
||||
class Status extends ActivityPubStatus
|
||||
{
|
||||
protected ?Episode $episode = null;
|
||||
|
||||
|
@ -41,12 +41,12 @@ class Note extends ActivityPubNote
|
|||
];
|
||||
|
||||
/**
|
||||
* Returns the note's attached episode
|
||||
* Returns the status' attached episode
|
||||
*/
|
||||
public function getEpisode(): ?Episode
|
||||
{
|
||||
if ($this->episode_id === null) {
|
||||
throw new RuntimeException('Note must have an episode_id before getting episode.');
|
||||
throw new RuntimeException('Status must have an episode_id before getting episode.');
|
||||
}
|
||||
|
||||
if ($this->episode === null) {
|
|
@ -26,7 +26,7 @@ return [
|
|||
one {# total share}
|
||||
other {# total shares}
|
||||
}',
|
||||
'total_notes' => '{numberOfTotalNotes, plural,
|
||||
'total_statuses' => '{numberOfTotalStatuses, plural,
|
||||
one {# note}
|
||||
other {# total notes}
|
||||
}',
|
||||
|
@ -112,8 +112,8 @@ return [
|
|||
'submit_edit' => 'Save episode',
|
||||
],
|
||||
'publish_form' => [
|
||||
'note' => 'Your note',
|
||||
'note_hint' =>
|
||||
'status' => 'Your note',
|
||||
'status_hint' =>
|
||||
'The message you write will be broadcasted to all your followers in the fediverse.',
|
||||
'publication_date' => 'Publication date',
|
||||
'publication_method' => [
|
||||
|
|
|
@ -223,7 +223,7 @@ return [
|
|||
one {<span class="font-semibold">#</span> follower}
|
||||
other {<span class="font-semibold">#</span> followers}
|
||||
}',
|
||||
'notes' => '{numberOfNotes, plural,
|
||||
'statuses' => '{numberOfStatuses, plural,
|
||||
one {<span class="font-semibold">#</span> note}
|
||||
other {<span class="font-semibold">#</span> notes}
|
||||
}',
|
||||
|
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
return [
|
||||
'title' => "{actorDisplayName}'s Note",
|
||||
'back_to_actor_notes' => 'Back to {actor} notes',
|
||||
'back_to_actor_statuses' => 'Back to {actor} notes',
|
||||
'actor_shared' => '{actor} shared',
|
||||
'reply_to' => 'Reply to @{actorUsername}',
|
||||
'form' => [
|
|
@ -26,7 +26,7 @@ return [
|
|||
one {# partage en tout}
|
||||
other {# partages en tout}
|
||||
}',
|
||||
'total_notes' => '{numberOfTotalNotes, plural,
|
||||
'total_statuses' => '{numberOfTotalStatuses, plural,
|
||||
one {# note}
|
||||
other {# notes}
|
||||
}',
|
||||
|
@ -115,8 +115,8 @@ return [
|
|||
'submit_edit' => 'Enregistrer l’épisode',
|
||||
],
|
||||
'publish_form' => [
|
||||
'note' => 'Votre note',
|
||||
'note_hint' =>
|
||||
'status' => 'Votre note',
|
||||
'status_hint' =>
|
||||
'Le message que vous écrirez sera diffusé à toutes les personnes qui vous suivent dans le fédiverse.',
|
||||
'publication_date' => 'Date de publication',
|
||||
'publication_date_clear' => 'Effacer la date de publication',
|
||||
|
|
|
@ -225,7 +225,7 @@ return [
|
|||
one {<span class="font-semibold">#</span> abonné·e}
|
||||
other {<span class="font-semibold">#</span> abonné·e·s}
|
||||
}',
|
||||
'notes' => '{numberOfNotes, plural,
|
||||
'notes' => '{numberOfStatuses, plural,
|
||||
one {<span class="font-semibold">#</span> note}
|
||||
other {<span class="font-semibold">#</span> notes}
|
||||
}',
|
||||
|
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
|
||||
return [
|
||||
'title' => 'Note de {actorDisplayName}',
|
||||
'back_to_actor_notes' => 'Retour aux notes de {actor}',
|
||||
'back_to_actor_statuses' => 'Retour aux notes de {actor}',
|
||||
'actor_shared' => '{actor} a partagé',
|
||||
'reply_to' => 'Répondre à @{actorUsername}',
|
||||
'form' => [
|
|
@ -14,19 +14,19 @@ declare(strict_types=1);
|
|||
namespace ActivityPub\Activities;
|
||||
|
||||
use ActivityPub\Core\Activity;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
|
||||
class AnnounceActivity extends Activity
|
||||
{
|
||||
protected string $type = 'Announce';
|
||||
|
||||
public function __construct(Note $reblogNote)
|
||||
public function __construct(Status $reblogStatus)
|
||||
{
|
||||
$this->actor = $reblogNote->actor->uri;
|
||||
$this->object = $reblogNote->reblog_of_note->uri;
|
||||
$this->actor = $reblogStatus->actor->uri;
|
||||
$this->object = $reblogStatus->reblog_of_status->uri;
|
||||
|
||||
$this->published = $reblogNote->published_at->format(DATE_W3C);
|
||||
$this->published = $reblogStatus->published_at->format(DATE_W3C);
|
||||
|
||||
$this->cc = [$reblogNote->actor->uri, $reblogNote->actor->followers_url];
|
||||
$this->cc = [$reblogStatus->actor->uri, $reblogStatus->actor->followers_url];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ $routes->addPlaceholder(
|
|||
'uuid',
|
||||
'[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}',
|
||||
);
|
||||
$routes->addPlaceholder('noteAction', '\bfavourite|\breblog|\breply');
|
||||
$routes->addPlaceholder('statusAction', '\bfavourite|\breblog|\breply');
|
||||
|
||||
/**
|
||||
* ActivityPub routes file
|
||||
|
@ -54,24 +54,24 @@ $routes->group('', [
|
|||
]);
|
||||
});
|
||||
|
||||
// Note
|
||||
$routes->post('notes/new', 'NoteController::attemptCreate/$1', [
|
||||
'as' => 'note-attempt-create',
|
||||
// Status
|
||||
$routes->post('statuses/new', 'StatusController::attemptCreate/$1', [
|
||||
'as' => 'status-attempt-create',
|
||||
]);
|
||||
|
||||
$routes->get('notes/(:uuid)', 'NoteController/$1', [
|
||||
'as' => 'note',
|
||||
$routes->get('statuses/(:uuid)', 'StatusController/$1', [
|
||||
'as' => 'status',
|
||||
]);
|
||||
|
||||
$routes->get('notes/(:uuid)/replies', 'NoteController/$1', [
|
||||
'as' => 'note-replies',
|
||||
$routes->get('statuses/(:uuid)/replies', 'StatusController/$1', [
|
||||
'as' => 'status-replies',
|
||||
]);
|
||||
|
||||
$routes->post(
|
||||
'notes/(:uuid)/remote/(:noteAction)',
|
||||
'NoteController::attemptRemoteAction/$1/$2/$3',
|
||||
'statuses/(:uuid)/remote/(:statusAction)',
|
||||
'StatusController::attemptRemoteAction/$1/$2/$3',
|
||||
[
|
||||
'as' => 'note-attempt-remote-action',
|
||||
'as' => 'status-attempt-remote-action',
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ActivityPub\Controllers;
|
|||
|
||||
use ActivityPub\Config\ActivityPub;
|
||||
use ActivityPub\Entities\Actor;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
use ActivityPub\Objects\OrderedCollectionObject;
|
||||
use ActivityPub\Objects\OrderedCollectionPage;
|
||||
use CodeIgniter\Controller;
|
||||
|
@ -101,30 +101,30 @@ class ActorController extends Controller
|
|||
->setJSON([]);
|
||||
}
|
||||
|
||||
$replyToNote = model('NoteModel')
|
||||
->getNoteByUri($payload->object->inReplyTo);
|
||||
$replyToStatus = model('StatusModel')
|
||||
->getStatusByUri($payload->object->inReplyTo);
|
||||
|
||||
$reply = null;
|
||||
if ($replyToNote !== null) {
|
||||
if ($replyToStatus !== null) {
|
||||
// TODO: strip content from html to retrieve message
|
||||
// remove all html tags and reconstruct message with mentions?
|
||||
extract_text_from_html($payload->object->content);
|
||||
$reply = new Note([
|
||||
$reply = new Status([
|
||||
'uri' => $payload->object->id,
|
||||
'actor_id' => $payloadActor->id,
|
||||
'in_reply_to_id' => $replyToNote->id,
|
||||
'in_reply_to_id' => $replyToStatus->id,
|
||||
'message' => $payload->object->content,
|
||||
'published_at' => Time::parse($payload->object->published),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($reply !== null) {
|
||||
$noteId = model('NoteModel')
|
||||
$statusId = model('StatusModel')
|
||||
->addReply($reply, true, false);
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
'note_id' => $noteId,
|
||||
'status_id' => $statusId,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -135,12 +135,12 @@ class ActorController extends Controller
|
|||
return $this->response->setStatusCode(501)
|
||||
->setJSON([]);
|
||||
case 'Delete':
|
||||
$noteToDelete = model('NoteModel')
|
||||
->getNoteByUri($payload->object->id);
|
||||
$statusToDelete = model('StatusModel')
|
||||
->getStatusByUri($payload->object->id);
|
||||
|
||||
if ($noteToDelete !== null) {
|
||||
model('NoteModel')
|
||||
->removeNote($noteToDelete, false);
|
||||
if ($statusToDelete !== null) {
|
||||
model('StatusModel')
|
||||
->removeStatus($statusToDelete, false);
|
||||
}
|
||||
|
||||
return $this->response->setStatusCode(200)
|
||||
|
@ -158,35 +158,35 @@ class ActorController extends Controller
|
|||
->setJSON([]);
|
||||
|
||||
case 'Like':
|
||||
// get favourited note
|
||||
$note = model('NoteModel')
|
||||
->getNoteByUri($payload->object);
|
||||
// get favourited status
|
||||
$status = model('StatusModel')
|
||||
->getStatusByUri($payload->object);
|
||||
|
||||
if ($note !== null) {
|
||||
if ($status !== null) {
|
||||
// Like side-effect
|
||||
model('FavouriteModel')
|
||||
->addFavourite($payloadActor, $note, false);
|
||||
->addFavourite($payloadActor, $status, false);
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
'note_id' => $note->id,
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->response->setStatusCode(200)
|
||||
->setJSON([]);
|
||||
case 'Announce':
|
||||
$note = model('NoteModel')
|
||||
->getNoteByUri($payload->object);
|
||||
$status = model('StatusModel')
|
||||
->getStatusByUri($payload->object);
|
||||
|
||||
if ($note !== null) {
|
||||
if ($status !== null) {
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
'note_id' => $note->id,
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
|
||||
model('NoteModel')
|
||||
->reblog($payloadActor, $note, false);
|
||||
model('StatusModel')
|
||||
->reblog($payloadActor, $status, false);
|
||||
}
|
||||
|
||||
return $this->response->setStatusCode(200)
|
||||
|
@ -204,45 +204,45 @@ class ActorController extends Controller
|
|||
return $this->response->setStatusCode(202)
|
||||
->setJSON([]);
|
||||
case 'Like':
|
||||
$note = model('NoteModel')
|
||||
->getNoteByUri($payload->object->object);
|
||||
$status = model('StatusModel')
|
||||
->getStatusByUri($payload->object->object);
|
||||
|
||||
if ($note !== null) {
|
||||
if ($status !== null) {
|
||||
// revert side-effect by removing favourite from database
|
||||
model('FavouriteModel')
|
||||
->removeFavourite($payloadActor, $note, false);
|
||||
->removeFavourite($payloadActor, $status, false);
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
'note_id' => $note->id,
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->response->setStatusCode(200)
|
||||
->setJSON([]);
|
||||
case 'Announce':
|
||||
$note = model('NoteModel')
|
||||
->getNoteByUri($payload->object->object);
|
||||
$status = model('StatusModel')
|
||||
->getStatusByUri($payload->object->object);
|
||||
|
||||
$reblogNote = null;
|
||||
if ($note !== null) {
|
||||
$reblogNote = model('NoteModel')
|
||||
$reblogStatus = null;
|
||||
if ($status !== null) {
|
||||
$reblogStatus = model('StatusModel')
|
||||
->where([
|
||||
'actor_id' => $payloadActor->id,
|
||||
'reblog_of_id' => service('uuid')
|
||||
->fromString($note->id)
|
||||
->fromString($status->id)
|
||||
->getBytes(),
|
||||
])
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($reblogNote !== null) {
|
||||
model('NoteModel')
|
||||
->undoReblog($reblogNote, false);
|
||||
if ($reblogStatus !== null) {
|
||||
model('StatusModel')
|
||||
->undoReblog($reblogStatus, false);
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
'note_id' => $note->id,
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class SchedulerController extends Controller
|
|||
// set activity status to delivered
|
||||
model('ActivityModel')
|
||||
->update($scheduledActivity->id, [
|
||||
'status' => 'delivered',
|
||||
'task_status' => 'delivered',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
namespace ActivityPub\Controllers;
|
||||
|
||||
use ActivityPub\Config\ActivityPub;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
use ActivityPub\Objects\OrderedCollectionObject;
|
||||
use ActivityPub\Objects\OrderedCollectionPage;
|
||||
use CodeIgniter\Controller;
|
||||
|
@ -21,14 +21,14 @@ use CodeIgniter\HTTP\Response;
|
|||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class NoteController extends Controller
|
||||
class StatusController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $helpers = ['activitypub'];
|
||||
|
||||
protected Note $note;
|
||||
protected Status $status;
|
||||
|
||||
protected ActivityPub $config;
|
||||
|
||||
|
@ -39,11 +39,11 @@ class NoteController extends Controller
|
|||
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (($note = model('NoteModel')->getNoteById($params[0])) === null) {
|
||||
if (($status = model('StatusModel')->getStatusById($params[0])) === null) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->note = $note;
|
||||
$this->status = $status;
|
||||
|
||||
unset($params[0]);
|
||||
|
||||
|
@ -56,7 +56,7 @@ class NoteController extends Controller
|
|||
public function index(): Response
|
||||
{
|
||||
$noteObjectClass = $this->config->noteObject;
|
||||
$noteObject = new $noteObjectClass($this->note);
|
||||
$noteObject = new $noteObjectClass($this->status);
|
||||
|
||||
return $this->response
|
||||
->setContentType('application/activity+json')
|
||||
|
@ -69,22 +69,22 @@ class NoteController extends Controller
|
|||
public function replies(): Response
|
||||
{
|
||||
/**
|
||||
* get note replies
|
||||
* get status replies
|
||||
*/
|
||||
$noteReplies = model('NoteModel')
|
||||
->where('in_reply_to_id', service('uuid') ->fromString($this->note->id) ->getBytes())
|
||||
$statusReplies = model('StatusModel')
|
||||
->where('in_reply_to_id', service('uuid') ->fromString($this->status->id) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC');
|
||||
|
||||
$pageNumber = (int) $this->request->getGet('page');
|
||||
|
||||
if ($pageNumber < 1) {
|
||||
$noteReplies->paginate(12);
|
||||
$pager = $noteReplies->pager;
|
||||
$statusReplies->paginate(12);
|
||||
$pager = $statusReplies->pager;
|
||||
$collection = new OrderedCollectionObject(null, $pager);
|
||||
} else {
|
||||
$paginatedReplies = $noteReplies->paginate(12, 'default', $pageNumber);
|
||||
$pager = $noteReplies->pager;
|
||||
$paginatedReplies = $statusReplies->paginate(12, 'default', $pageNumber);
|
||||
$pager = $statusReplies->pager;
|
||||
|
||||
$orderedItems = [];
|
||||
$noteObjectClass = $this->config->noteObject;
|
||||
|
@ -118,21 +118,21 @@ class NoteController extends Controller
|
|||
->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$newNote = new Note([
|
||||
$newStatus = new Status([
|
||||
'actor_id' => $this->request->getPost('actor_id'),
|
||||
'message' => $this->request->getPost('message'),
|
||||
'published_at' => Time::now(),
|
||||
]);
|
||||
|
||||
if (! model('NoteModel')->addNote($newNote)) {
|
||||
if (! model('StatusModel')->addStatus($newStatus)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
// TODO: translate
|
||||
->with('error', "Couldn't create Note");
|
||||
->with('error', "Couldn't create Status");
|
||||
}
|
||||
|
||||
// Note without preview card has been successfully created
|
||||
// Status without preview card has been successfully created
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ class NoteController extends Controller
|
|||
->getActorById($this->request->getPost('actor_id'));
|
||||
|
||||
model('FavouriteModel')
|
||||
->toggleFavourite($actor, $this->note->id);
|
||||
->toggleFavourite($actor, $this->status->id);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
@ -174,8 +174,8 @@ class NoteController extends Controller
|
|||
$actor = model('ActorModel')
|
||||
->getActorById($this->request->getPost('actor_id'));
|
||||
|
||||
model('NoteModel')
|
||||
->toggleReblog($actor, $this->note);
|
||||
model('StatusModel')
|
||||
->toggleReblog($actor, $this->status);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
@ -194,14 +194,14 @@ class NoteController extends Controller
|
|||
->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$newReplyNote = new Note([
|
||||
$newReplyStatus = new Status([
|
||||
'actor_id' => $this->request->getPost('actor_id'),
|
||||
'in_reply_to_id' => $this->note->id,
|
||||
'in_reply_to_id' => $this->status->id,
|
||||
'message' => $this->request->getPost('message'),
|
||||
'published_at' => Time::now(),
|
||||
]);
|
||||
|
||||
if (! model('NoteModel')->addReply($newReplyNote)) {
|
||||
if (! model('StatusModel')->addReply($newReplyStatus)) {
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
|
@ -209,7 +209,7 @@ class NoteController extends Controller
|
|||
->with('error', "Couldn't create Reply");
|
||||
}
|
||||
|
||||
// Reply note without preview card has been successfully created
|
||||
// Reply status without preview card has been successfully created
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
@ -249,33 +249,33 @@ class NoteController extends Controller
|
|||
);
|
||||
|
||||
if (! $ostatusKey) {
|
||||
// TODO: error, couldn't remote favourite/share/reply to note
|
||||
// The instance doesn't allow its users remote actions on notes
|
||||
// TODO: error, couldn't remote favourite/share/reply to status
|
||||
// The instance doesn't allow its users remote actions on statuses
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
|
||||
return redirect()->to(
|
||||
str_replace('{uri}', urlencode($this->note->uri), $data->links[$ostatusKey]->template),
|
||||
str_replace('{uri}', urlencode($this->status->uri), $data->links[$ostatusKey]->template),
|
||||
);
|
||||
}
|
||||
|
||||
public function attemptBlockActor(): RedirectResponse
|
||||
{
|
||||
model('ActorModel')->blockActor($this->note->actor->id);
|
||||
model('ActorModel')->blockActor($this->status->actor->id);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function attemptBlockDomain(): RedirectResponse
|
||||
{
|
||||
model('BlockedDomainModel')->blockDomain($this->note->actor->domain);
|
||||
model('BlockedDomainModel')->blockDomain($this->status->actor->domain);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function attemptDelete(): RedirectResponse
|
||||
{
|
||||
model('NoteModel', false)->removeNote($this->note);
|
||||
model('StatusModel', false)->removeStatus($this->status);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
|
@ -93,7 +93,7 @@ class AddActors extends Migration
|
|||
'unsigned' => true,
|
||||
'default' => 0,
|
||||
],
|
||||
'notes_count' => [
|
||||
'statuses_count' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'default' => 0,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Class AddNotes Creates activitypub_notes table in database
|
||||
* Class AddStatuses Creates activitypub_statuses table in database
|
||||
*
|
||||
* @copyright 2021 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -14,7 +14,7 @@ namespace ActivityPub\Database\Migrations;
|
|||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddNotes extends Migration
|
||||
class AddStatuses extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
|
@ -76,16 +76,16 @@ class AddNotes extends Migration
|
|||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addUniqueKey('uri');
|
||||
// FIXME: an actor must reblog a note only once
|
||||
// FIXME: an actor must reblog a status only once
|
||||
// $this->forge->addUniqueKey(['actor_id', 'reblog_of_id']);
|
||||
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('in_reply_to_id', 'activitypub_notes', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('reblog_of_id', 'activitypub_notes', 'id', '', 'CASCADE');
|
||||
$this->forge->createTable('activitypub_notes');
|
||||
$this->forge->addForeignKey('in_reply_to_id', 'activitypub_statuses', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('reblog_of_id', 'activitypub_statuses', 'id', '', 'CASCADE');
|
||||
$this->forge->createTable('activitypub_statuses');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('activitypub_notes');
|
||||
$this->forge->dropTable('activitypub_statuses');
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ class AddActivities extends Migration
|
|||
'unsigned' => true,
|
||||
'null' => true,
|
||||
],
|
||||
'note_id' => [
|
||||
'status_id' => [
|
||||
'type' => 'BINARY',
|
||||
'constraint' => 16,
|
||||
'null' => true,
|
||||
|
@ -44,7 +44,7 @@ class AddActivities extends Migration
|
|||
'payload' => [
|
||||
'type' => 'JSON',
|
||||
],
|
||||
'status' => [
|
||||
'task_status' => [
|
||||
'type' => 'ENUM',
|
||||
'constraint' => ['queued', 'delivered'],
|
||||
'null' => true,
|
||||
|
@ -62,7 +62,7 @@ class AddActivities extends Migration
|
|||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('target_actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('note_id', 'activitypub_notes', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('status_id', 'activitypub_statuses', 'id', '', 'CASCADE');
|
||||
$this->forge->createTable('activitypub_activities');
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,15 @@ class AddFavourites extends Migration
|
|||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
],
|
||||
'note_id' => [
|
||||
'status_id' => [
|
||||
'type' => 'BINARY',
|
||||
'constraint' => 16,
|
||||
],
|
||||
]);
|
||||
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
|
||||
$this->forge->addPrimaryKey(['actor_id', 'note_id']);
|
||||
$this->forge->addPrimaryKey(['actor_id', 'status_id']);
|
||||
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('note_id', 'activitypub_notes', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('status_id', 'activitypub_statuses', 'id', '', 'CASCADE');
|
||||
$this->forge->createTable('activitypub_favourites');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Class AddNotePreviewCards Creates activitypub_notes_preview_cards table in database
|
||||
* Class AddStatusesPreviewCards Creates activitypub_statuses_preview_cards table in database
|
||||
*
|
||||
* @copyright 2021 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
|
@ -14,12 +14,12 @@ namespace ActivityPub\Database\Migrations;
|
|||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class AddNotesPreviewCards extends Migration
|
||||
class AddStatusesPreviewCards extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'note_id' => [
|
||||
'status_id' => [
|
||||
'type' => 'BINARY',
|
||||
'constraint' => 16,
|
||||
],
|
||||
|
@ -29,14 +29,14 @@ class AddNotesPreviewCards extends Migration
|
|||
],
|
||||
]);
|
||||
|
||||
$this->forge->addPrimaryKey(['note_id', 'preview_card_id']);
|
||||
$this->forge->addForeignKey('note_id', 'activitypub_notes', 'id', '', 'CASCADE');
|
||||
$this->forge->addPrimaryKey(['status_id', 'preview_card_id']);
|
||||
$this->forge->addForeignKey('status_id', 'activitypub_statuses', 'id', '', 'CASCADE');
|
||||
$this->forge->addForeignKey('preview_card_id', 'activitypub_preview_cards', 'id', '', 'CASCADE');
|
||||
$this->forge->createTable('activitypub_notes_preview_cards');
|
||||
$this->forge->createTable('activitypub_statuses_preview_cards');
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('activitypub_notes_preview_cards');
|
||||
$this->forge->dropTable('activitypub_statuses_preview_cards');
|
||||
}
|
||||
}
|
|
@ -19,11 +19,11 @@ use RuntimeException;
|
|||
* @property Actor $actor
|
||||
* @property int|null $target_actor_id
|
||||
* @property Actor $target_actor
|
||||
* @property string|null $note_id
|
||||
* @property Note $note
|
||||
* @property string|null $status_id
|
||||
* @property Status $status
|
||||
* @property string $type
|
||||
* @property object $payload
|
||||
* @property string|null $status
|
||||
* @property string|null $task_status
|
||||
* @property Time|null $scheduled_at
|
||||
* @property Time $created_at
|
||||
*/
|
||||
|
@ -33,12 +33,12 @@ class Activity extends UuidEntity
|
|||
|
||||
protected ?Actor $target_actor = null;
|
||||
|
||||
protected ?Note $note = null;
|
||||
protected ?Status $status = null;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $uuids = ['id', 'note_id'];
|
||||
protected $uuids = ['id', 'status_id'];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
|
@ -52,10 +52,10 @@ class Activity extends UuidEntity
|
|||
'id' => 'string',
|
||||
'actor_id' => 'integer',
|
||||
'target_actor_id' => '?integer',
|
||||
'note_id' => '?string',
|
||||
'status_id' => '?string',
|
||||
'type' => 'string',
|
||||
'payload' => 'json',
|
||||
'status' => '?string',
|
||||
'task_status' => '?string',
|
||||
];
|
||||
|
||||
public function getActor(): Actor
|
||||
|
@ -86,17 +86,17 @@ class Activity extends UuidEntity
|
|||
return $this->target_actor;
|
||||
}
|
||||
|
||||
public function getNote(): Note
|
||||
public function getStatus(): Status
|
||||
{
|
||||
if ($this->note_id === null) {
|
||||
throw new RuntimeException('Activity must have a note_id before getting note.');
|
||||
if ($this->status_id === null) {
|
||||
throw new RuntimeException('Activity must have a status_id before getting status.');
|
||||
}
|
||||
|
||||
if ($this->note === null) {
|
||||
$this->note = model('NoteModel', false)
|
||||
->getNoteById($this->note_id);
|
||||
if ($this->status === null) {
|
||||
$this->status = model('StatusModel', false)
|
||||
->getStatusById($this->status_id);
|
||||
}
|
||||
|
||||
return $this->note;
|
||||
return $this->status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use RuntimeException;
|
|||
* @property string|null $outbox_url
|
||||
* @property string|null $followers_url
|
||||
* @property int $followers_count
|
||||
* @property int $notes_count
|
||||
* @property int $statuses_count
|
||||
* @property bool $is_blocked
|
||||
*
|
||||
* @property Actor[] $followers
|
||||
|
@ -68,7 +68,7 @@ class Actor extends Entity
|
|||
'outbox_url' => '?string',
|
||||
'followers_url' => '?string',
|
||||
'followers_count' => 'integer',
|
||||
'notes_count' => 'integer',
|
||||
'statuses_count' => 'integer',
|
||||
'is_blocked' => 'boolean',
|
||||
];
|
||||
|
||||
|
|
|
@ -14,20 +14,20 @@ use Michalsn\Uuid\UuidEntity;
|
|||
|
||||
/**
|
||||
* @property int $actor_id
|
||||
* @property string $note_id
|
||||
* @property string $status_id
|
||||
*/
|
||||
class Favourite extends UuidEntity
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $uuids = ['note_id'];
|
||||
protected $uuids = ['status_id'];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'actor_id' => 'integer',
|
||||
'note_id' => 'string',
|
||||
'status_id' => 'string',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use CodeIgniter\Entity\Entity;
|
|||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $note_id
|
||||
* @property string $status_id
|
||||
* @property string $url
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
|
@ -33,7 +33,7 @@ class PreviewCard extends Entity
|
|||
*/
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'note_id' => 'string',
|
||||
'status_id' => 'string',
|
||||
'url' => 'string',
|
||||
'title' => 'string',
|
||||
'description' => 'string',
|
||||
|
|
|
@ -20,9 +20,9 @@ use RuntimeException;
|
|||
* @property int $actor_id
|
||||
* @property Actor $actor
|
||||
* @property string|null $in_reply_to_id
|
||||
* @property Note|null $reply_to_note
|
||||
* @property Status|null $reply_to_status
|
||||
* @property string|null $reblog_of_id
|
||||
* @property Note|null $reblog_of_note
|
||||
* @property Status|null $reblog_of_status
|
||||
* @property string $message
|
||||
* @property string $message_html
|
||||
* @property int $favourites_count
|
||||
|
@ -35,30 +35,30 @@ use RuntimeException;
|
|||
* @property PreviewCard|null $preview_card
|
||||
*
|
||||
* @property bool $has_replies
|
||||
* @property Note[] $replies
|
||||
* @property Note[] $reblogs
|
||||
* @property Status[] $replies
|
||||
* @property Status[] $reblogs
|
||||
*/
|
||||
class Note extends UuidEntity
|
||||
class Status extends UuidEntity
|
||||
{
|
||||
protected ?Actor $actor = null;
|
||||
|
||||
protected ?Note $reply_to_note = null;
|
||||
protected ?Status $reply_to_status = null;
|
||||
|
||||
protected ?Note $reblog_of_note = null;
|
||||
protected ?Status $reblog_of_status = null;
|
||||
|
||||
protected ?PreviewCard $preview_card = null;
|
||||
|
||||
protected bool $has_preview_card = false;
|
||||
|
||||
/**
|
||||
* @var Note[]|null
|
||||
* @var Status[]|null
|
||||
*/
|
||||
protected ?array $replies = null;
|
||||
|
||||
protected bool $has_replies = false;
|
||||
|
||||
/**
|
||||
* @var Note[]|null
|
||||
* @var Status[]|null
|
||||
*/
|
||||
protected ?array $reblogs = null;
|
||||
|
||||
|
@ -89,12 +89,12 @@ class Note extends UuidEntity
|
|||
];
|
||||
|
||||
/**
|
||||
* Returns the note's actor
|
||||
* Returns the status's actor
|
||||
*/
|
||||
public function getActor(): Actor
|
||||
{
|
||||
if ($this->actor_id === null) {
|
||||
throw new RuntimeException('Note must have an actor_id before getting actor.');
|
||||
throw new RuntimeException('Status must have an actor_id before getting actor.');
|
||||
}
|
||||
|
||||
if ($this->actor === null) {
|
||||
|
@ -108,12 +108,12 @@ class Note extends UuidEntity
|
|||
public function getPreviewCard(): ?PreviewCard
|
||||
{
|
||||
if ($this->id === null) {
|
||||
throw new RuntimeException('Note must be created before getting preview_card.');
|
||||
throw new RuntimeException('Status must be created before getting preview_card.');
|
||||
}
|
||||
|
||||
if ($this->preview_card === null) {
|
||||
$this->preview_card = model('PreviewCardModel', false)
|
||||
->getNotePreviewCard($this->id);
|
||||
->getStatusPreviewCard($this->id);
|
||||
}
|
||||
|
||||
return $this->preview_card;
|
||||
|
@ -125,17 +125,17 @@ class Note extends UuidEntity
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getReplies(): array
|
||||
{
|
||||
if ($this->id === null) {
|
||||
throw new RuntimeException('Note must be created before getting replies.');
|
||||
throw new RuntimeException('Status must be created before getting replies.');
|
||||
}
|
||||
|
||||
if ($this->replies === null) {
|
||||
$this->replies = (array) model('NoteModel', false)
|
||||
->getNoteReplies($this->id);
|
||||
$this->replies = (array) model('StatusModel', false)
|
||||
->getStatusReplies($this->id);
|
||||
}
|
||||
|
||||
return $this->replies;
|
||||
|
@ -146,49 +146,49 @@ class Note extends UuidEntity
|
|||
return $this->getReplies() !== null;
|
||||
}
|
||||
|
||||
public function getReplyToNote(): ?self
|
||||
public function getReplyToStatus(): ?self
|
||||
{
|
||||
if ($this->in_reply_to_id === null) {
|
||||
throw new RuntimeException('Note is not a reply.');
|
||||
throw new RuntimeException('Status is not a reply.');
|
||||
}
|
||||
|
||||
if ($this->reply_to_note === null) {
|
||||
$this->reply_to_note = model('NoteModel', false)
|
||||
->getNoteById($this->in_reply_to_id);
|
||||
if ($this->reply_to_status === null) {
|
||||
$this->reply_to_status = model('StatusModel', false)
|
||||
->getStatusById($this->in_reply_to_id);
|
||||
}
|
||||
|
||||
return $this->reply_to_note;
|
||||
return $this->reply_to_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getReblogs(): array
|
||||
{
|
||||
if ($this->id === null) {
|
||||
throw new RuntimeException('Note must be created before getting reblogs.');
|
||||
throw new RuntimeException('Status must be created before getting reblogs.');
|
||||
}
|
||||
|
||||
if ($this->reblogs === null) {
|
||||
$this->reblogs = (array) model('NoteModel', false)
|
||||
->getNoteReblogs($this->id);
|
||||
$this->reblogs = (array) model('StatusModel', false)
|
||||
->getStatusReblogs($this->id);
|
||||
}
|
||||
|
||||
return $this->reblogs;
|
||||
}
|
||||
|
||||
public function getReblogOfNote(): ?self
|
||||
public function getReblogOfStatus(): ?self
|
||||
{
|
||||
if ($this->reblog_of_id === null) {
|
||||
throw new RuntimeException('Note is not a reblog.');
|
||||
throw new RuntimeException('Status is not a reblog.');
|
||||
}
|
||||
|
||||
if ($this->reblog_of_note === null) {
|
||||
$this->reblog_of_note = model('NoteModel', false)
|
||||
->getNoteById($this->reblog_of_id);
|
||||
if ($this->reblog_of_status === null) {
|
||||
$this->reblog_of_status = model('StatusModel', false)
|
||||
->getStatusById($this->reblog_of_id);
|
||||
}
|
||||
|
||||
return $this->reblog_of_note;
|
||||
return $this->reblog_of_status;
|
||||
}
|
||||
|
||||
public function setMessage(string $message): static
|
|
@ -31,7 +31,7 @@ class ActivityModel extends UuidModel
|
|||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $uuidFields = ['id', 'note_id'];
|
||||
protected $uuidFields = ['id', 'status_id'];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
|
@ -40,10 +40,10 @@ class ActivityModel extends UuidModel
|
|||
'id',
|
||||
'actor_id',
|
||||
'target_actor_id',
|
||||
'note_id',
|
||||
'status_id',
|
||||
'type',
|
||||
'payload',
|
||||
'status',
|
||||
'task_status',
|
||||
'scheduled_at',
|
||||
];
|
||||
|
||||
|
@ -88,20 +88,20 @@ class ActivityModel extends UuidModel
|
|||
string $type,
|
||||
int $actorId,
|
||||
?int $targetActorId,
|
||||
?string $noteId,
|
||||
?string $statusId,
|
||||
string $payload,
|
||||
DateTimeInterface $scheduledAt = null,
|
||||
?string $status = null
|
||||
?string $taskStatus = null
|
||||
): BaseResult | int | string | false {
|
||||
return $this->insert(
|
||||
[
|
||||
'actor_id' => $actorId,
|
||||
'target_actor_id' => $targetActorId,
|
||||
'note_id' => $noteId,
|
||||
'status_id' => $statusId,
|
||||
'type' => $type,
|
||||
'payload' => $payload,
|
||||
'scheduled_at' => $scheduledAt,
|
||||
'status' => $status,
|
||||
'task_status' => $taskStatus,
|
||||
],
|
||||
true,
|
||||
);
|
||||
|
|
|
@ -41,7 +41,7 @@ class ActorModel extends Model
|
|||
'outbox_url',
|
||||
'followers_url',
|
||||
'followers_count',
|
||||
'notes_count',
|
||||
'statuses_count',
|
||||
'is_blocked',
|
||||
];
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use ActivityPub\Activities\LikeActivity;
|
|||
use ActivityPub\Activities\UndoActivity;
|
||||
use ActivityPub\Entities\Actor;
|
||||
use ActivityPub\Entities\Favourite;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
use CodeIgniter\Events\Events;
|
||||
use Michalsn\Uuid\UuidModel;
|
||||
|
||||
|
@ -28,12 +28,12 @@ class FavouriteModel extends UuidModel
|
|||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $uuidFields = ['note_id'];
|
||||
protected $uuidFields = ['status_id'];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $allowedFields = ['actor_id', 'note_id'];
|
||||
protected $allowedFields = ['actor_id', 'status_id'];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -47,32 +47,32 @@ class FavouriteModel extends UuidModel
|
|||
|
||||
protected $updatedField;
|
||||
|
||||
public function addFavourite(Actor $actor, Note $note, bool $registerActivity = true): void
|
||||
public function addFavourite(Actor $actor, Status $status, bool $registerActivity = true): void
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$this->insert([
|
||||
'actor_id' => $actor->id,
|
||||
'note_id' => $note->id,
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes())
|
||||
model('StatusModel')
|
||||
->where('id', service('uuid') ->fromString($status->id) ->getBytes())
|
||||
->increment('favourites_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
$likeActivity = new LikeActivity();
|
||||
$likeActivity->set('actor', $actor->uri)
|
||||
->set('object', $note->uri);
|
||||
->set('object', $status->uri);
|
||||
|
||||
$activityId = model('ActivityModel')
|
||||
->newActivity(
|
||||
'Like',
|
||||
$actor->id,
|
||||
null,
|
||||
$note->id,
|
||||
$status->id,
|
||||
$likeActivity->toJSON(),
|
||||
$note->published_at,
|
||||
$status->published_at,
|
||||
'queued',
|
||||
);
|
||||
|
||||
|
@ -84,28 +84,28 @@ class FavouriteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
Events::trigger('on_note_favourite', $actor, $note);
|
||||
Events::trigger('on_status_favourite', $actor, $status);
|
||||
|
||||
model('NoteModel')
|
||||
->clearCache($note);
|
||||
model('StatusModel')
|
||||
->clearCache($status);
|
||||
|
||||
$this->db->transComplete();
|
||||
}
|
||||
|
||||
public function removeFavourite(Actor $actor, Note $note, bool $registerActivity = true): void
|
||||
public function removeFavourite(Actor $actor, Status $status, bool $registerActivity = true): void
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', service('uuid') ->fromString($note->id) ->getBytes())
|
||||
model('StatusModel')
|
||||
->where('id', service('uuid') ->fromString($status->id) ->getBytes())
|
||||
->decrement('favourites_count');
|
||||
|
||||
$this->db
|
||||
->table('activitypub_favourites')
|
||||
->where([
|
||||
'actor_id' => $actor->id,
|
||||
'note_id' => service('uuid')
|
||||
->fromString($note->id)
|
||||
'status_id' => service('uuid')
|
||||
->fromString($status->id)
|
||||
->getBytes(),
|
||||
])
|
||||
->delete();
|
||||
|
@ -117,8 +117,8 @@ class FavouriteModel extends UuidModel
|
|||
->where([
|
||||
'type' => 'Like',
|
||||
'actor_id' => $actor->id,
|
||||
'note_id' => service('uuid')
|
||||
->fromString($note->id)
|
||||
'status_id' => service('uuid')
|
||||
->fromString($status->id)
|
||||
->getBytes(),
|
||||
])
|
||||
->first();
|
||||
|
@ -127,7 +127,7 @@ class FavouriteModel extends UuidModel
|
|||
$likeActivity
|
||||
->set('id', base_url(route_to('activity', $actor->username, $activity->id)))
|
||||
->set('actor', $actor->uri)
|
||||
->set('object', $note->uri);
|
||||
->set('object', $status->uri);
|
||||
|
||||
$undoActivity
|
||||
->set('actor', $actor->uri)
|
||||
|
@ -138,9 +138,9 @@ class FavouriteModel extends UuidModel
|
|||
'Undo',
|
||||
$actor->id,
|
||||
null,
|
||||
$note->id,
|
||||
$status->id,
|
||||
$undoActivity->toJSON(),
|
||||
$note->published_at,
|
||||
$status->published_at,
|
||||
'queued',
|
||||
);
|
||||
|
||||
|
@ -152,10 +152,10 @@ class FavouriteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
Events::trigger('on_note_undo_favourite', $actor, $note);
|
||||
Events::trigger('on_status_undo_favourite', $actor, $status);
|
||||
|
||||
model('NoteModel')
|
||||
->clearCache($note);
|
||||
model('StatusModel')
|
||||
->clearCache($status);
|
||||
|
||||
$this->db->transComplete();
|
||||
}
|
||||
|
@ -163,19 +163,19 @@ class FavouriteModel extends UuidModel
|
|||
/**
|
||||
* Adds or removes favourite from database and increments count
|
||||
*/
|
||||
public function toggleFavourite(Actor $actor, Note $note): void
|
||||
public function toggleFavourite(Actor $actor, Status $status): void
|
||||
{
|
||||
if (
|
||||
$this->where([
|
||||
'actor_id' => $actor->id,
|
||||
'note_id' => service('uuid')
|
||||
->fromString($note->id)
|
||||
'status_id' => service('uuid')
|
||||
->fromString($status->id)
|
||||
->getBytes(),
|
||||
])->first()
|
||||
) {
|
||||
$this->removeFavourite($actor, $note);
|
||||
$this->removeFavourite($actor, $status);
|
||||
} else {
|
||||
$this->addFavourite($actor, $note);
|
||||
$this->addFavourite($actor, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,18 +70,18 @@ class PreviewCardModel extends Model
|
|||
return $found;
|
||||
}
|
||||
|
||||
public function getNotePreviewCard(string $noteId): ?PreviewCard
|
||||
public function getStatusPreviewCard(string $statusId): ?PreviewCard
|
||||
{
|
||||
$cacheName =
|
||||
config('ActivityPub')
|
||||
->cachePrefix . "note#{$noteId}_preview_card";
|
||||
->cachePrefix . "status#{$statusId}_preview_card";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->join(
|
||||
'activitypub_notes_preview_cards',
|
||||
'activitypub_notes_preview_cards.preview_card_id = id',
|
||||
'activitypub_statuses_preview_cards',
|
||||
'activitypub_statuses_preview_cards.preview_card_id = id',
|
||||
'inner',
|
||||
)
|
||||
->where('note_id', service('uuid') ->fromString($noteId) ->getBytes())
|
||||
->where('status_id', service('uuid') ->fromString($statusId) ->getBytes())
|
||||
->first();
|
||||
|
||||
cache()
|
||||
|
|
|
@ -15,7 +15,7 @@ use ActivityPub\Activities\CreateActivity;
|
|||
use ActivityPub\Activities\DeleteActivity;
|
||||
use ActivityPub\Activities\UndoActivity;
|
||||
use ActivityPub\Entities\Actor;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
use ActivityPub\Objects\TombstoneObject;
|
||||
use CodeIgniter\Database\BaseResult;
|
||||
use CodeIgniter\Database\Query;
|
||||
|
@ -25,12 +25,12 @@ use CodeIgniter\I18n\Time;
|
|||
use Exception;
|
||||
use Michalsn\Uuid\UuidModel;
|
||||
|
||||
class NoteModel extends UuidModel
|
||||
class StatusModel extends UuidModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'activitypub_notes';
|
||||
protected $table = 'activitypub_statuses';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -62,7 +62,7 @@ class NoteModel extends UuidModel
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $returnType = Note::class;
|
||||
protected $returnType = Status::class;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
@ -87,14 +87,14 @@ class NoteModel extends UuidModel
|
|||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $beforeInsert = ['setNoteId'];
|
||||
protected $beforeInsert = ['setStatusId'];
|
||||
|
||||
public function getNoteById(string $noteId): ?Note
|
||||
public function getStatusById(string $statusId): ?Status
|
||||
{
|
||||
$cacheName = config('ActivityPub')
|
||||
->cachePrefix . "note#{$noteId}";
|
||||
->cachePrefix . "status#{$statusId}";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->find($noteId);
|
||||
$found = $this->find($statusId);
|
||||
|
||||
cache()
|
||||
->save($cacheName, $found, DECADE);
|
||||
|
@ -103,14 +103,14 @@ class NoteModel extends UuidModel
|
|||
return $found;
|
||||
}
|
||||
|
||||
public function getNoteByUri(string $noteUri): ?Note
|
||||
public function getStatusByUri(string $statusUri): ?Status
|
||||
{
|
||||
$hashedNoteUri = md5($noteUri);
|
||||
$hashedStatusUri = md5($statusUri);
|
||||
$cacheName =
|
||||
config('ActivityPub')
|
||||
->cachePrefix . "note-{$hashedNoteUri}";
|
||||
->cachePrefix . "status-{$hashedStatusUri}";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->where('uri', $noteUri)
|
||||
$found = $this->where('uri', $statusUri)
|
||||
->first();
|
||||
|
||||
cache()
|
||||
|
@ -121,16 +121,16 @@ class NoteModel extends UuidModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves all published notes for a given actor ordered by publication date
|
||||
* Retrieves all published statuses for a given actor ordered by publication date
|
||||
*
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getActorPublishedNotes(int $actorId): array
|
||||
public function getActorPublishedStatuses(int $actorId): array
|
||||
{
|
||||
$cacheName =
|
||||
config('ActivityPub')
|
||||
->cachePrefix .
|
||||
"actor#{$actorId}_published_notes";
|
||||
"actor#{$actorId}_published_statuses";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = $this->where([
|
||||
'actor_id' => $actorId,
|
||||
|
@ -140,20 +140,20 @@ class NoteModel extends UuidModel
|
|||
->orderBy('published_at', 'DESC')
|
||||
->findAll();
|
||||
|
||||
$secondsToNextUnpublishedNote = $this->getSecondsToNextUnpublishedNote($actorId);
|
||||
$secondsToNextUnpublishedStatus = $this->getSecondsToNextUnpublishedStatuses($actorId);
|
||||
|
||||
cache()
|
||||
->save($cacheName, $found, $secondsToNextUnpublishedNote ? $secondsToNextUnpublishedNote : DECADE);
|
||||
->save($cacheName, $found, $secondsToNextUnpublishedStatus ? $secondsToNextUnpublishedStatus : DECADE);
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp difference in seconds between the next note to publish and the current timestamp. Returns
|
||||
* false if there's no note to publish
|
||||
* Returns the timestamp difference in seconds between the next status to publish and the current timestamp. Returns
|
||||
* false if there's no status to publish
|
||||
*/
|
||||
public function getSecondsToNextUnpublishedNote(int $actorId): int | false
|
||||
public function getSecondsToNextUnpublishedStatuses(int $actorId): int | false
|
||||
{
|
||||
$result = $this->select('TIMESTAMPDIFF(SECOND, NOW(), `published_at`) as timestamp_diff')
|
||||
->where([
|
||||
|
@ -170,26 +170,26 @@ class NoteModel extends UuidModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves all published replies for a given note. By default, it does not get replies from blocked actors.
|
||||
* Retrieves all published replies for a given status. By default, it does not get replies from blocked actors.
|
||||
*
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getNoteReplies(string $noteId, bool $withBlocked = false): array
|
||||
public function getStatusReplies(string $statusId, bool $withBlocked = false): array
|
||||
{
|
||||
$cacheName =
|
||||
config('ActivityPub')
|
||||
->cachePrefix .
|
||||
"note#{$noteId}_replies" .
|
||||
"status#{$statusId}_replies" .
|
||||
($withBlocked ? '_withBlocked' : '');
|
||||
|
||||
if (! ($found = cache($cacheName))) {
|
||||
if (! $withBlocked) {
|
||||
$this->select('activitypub_notes.*')
|
||||
->join('activitypub_actors', 'activitypub_actors.id = activitypub_notes.actor_id', 'inner')
|
||||
$this->select('activitypub_statuses.*')
|
||||
->join('activitypub_actors', 'activitypub_actors.id = activitypub_statuses.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($statusId) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC');
|
||||
$found = $this->findAll();
|
||||
|
@ -202,18 +202,18 @@ class NoteModel extends UuidModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves all published reblogs for a given note
|
||||
* Retrieves all published reblogs for a given status
|
||||
*
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getNoteReblogs(string $noteId): array
|
||||
public function getStatusReblogs(string $statusId): array
|
||||
{
|
||||
$cacheName =
|
||||
config('ActivityPub')
|
||||
->cachePrefix . "note#{$noteId}_reblogs";
|
||||
->cachePrefix . "status#{$statusId}_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($statusId) ->getBytes())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->orderBy('published_at', 'ASC')
|
||||
->findAll();
|
||||
|
@ -225,23 +225,23 @@ class NoteModel extends UuidModel
|
|||
return $found;
|
||||
}
|
||||
|
||||
public function addPreviewCard(string $noteId, int $previewCardId): Query | bool
|
||||
public function addPreviewCard(string $statusId, int $previewCardId): Query | bool
|
||||
{
|
||||
return $this->db->table('activitypub_notes_preview_cards')
|
||||
return $this->db->table('activitypub_statuses_preview_cards')
|
||||
->insert([
|
||||
'note_id' => $this->uuid->fromString($noteId)
|
||||
'status_id' => $this->uuid->fromString($statusId)
|
||||
->getBytes(),
|
||||
'preview_card_id' => $previewCardId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds note in database along preview card if relevant
|
||||
* Adds status in database along preview card if relevant
|
||||
*
|
||||
* @return string|false returns the new note id if success or false otherwise
|
||||
* @return string|false returns the new status id if success or false otherwise
|
||||
*/
|
||||
public function addNote(
|
||||
Note $note,
|
||||
public function addStatus(
|
||||
Status $status,
|
||||
bool $createPreviewCard = true,
|
||||
bool $registerActivity = true
|
||||
): string | false {
|
||||
|
@ -249,56 +249,56 @@ class NoteModel extends UuidModel
|
|||
|
||||
$this->db->transStart();
|
||||
|
||||
if (! ($newNoteId = $this->insert($note, true))) {
|
||||
if (! ($newStatusId = $this->insert($status, true))) {
|
||||
$this->db->transRollback();
|
||||
|
||||
// Couldn't insert note
|
||||
// Couldn't insert status
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($createPreviewCard) {
|
||||
// parse message
|
||||
$messageUrls = extract_urls_from_message($note->message);
|
||||
$messageUrls = extract_urls_from_message($status->message);
|
||||
|
||||
if (
|
||||
$messageUrls !== [] &&
|
||||
($previewCard = get_or_create_preview_card_from_url(new URI($messageUrls[0]))) &&
|
||||
! $this->addPreviewCard($newNoteId, $previewCard->id)
|
||||
! $this->addPreviewCard($newStatusId, $previewCard->id)
|
||||
) {
|
||||
$this->db->transRollback();
|
||||
// problem when linking note to preview card
|
||||
// problem when linking status to preview card
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
model('ActorModel')
|
||||
->where('id', $note->actor_id)
|
||||
->increment('notes_count');
|
||||
->where('id', $status->actor_id)
|
||||
->increment('statuses_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
// set note id and uri to construct NoteObject
|
||||
$note->id = $newNoteId;
|
||||
$note->uri = base_url(route_to('note', $note->actor->username, $newNoteId));
|
||||
// set status id and uri to construct NoteObject
|
||||
$status->id = $newStatusId;
|
||||
$status->uri = base_url(route_to('status', $status->actor->username, $newStatusId));
|
||||
|
||||
$createActivity = new CreateActivity();
|
||||
$noteObjectClass = config('ActivityPub')
|
||||
->noteObject;
|
||||
$createActivity
|
||||
->set('actor', $note->actor->uri)
|
||||
->set('object', new $noteObjectClass($note));
|
||||
->set('actor', $status->actor->uri)
|
||||
->set('object', new $noteObjectClass($status));
|
||||
|
||||
$activityId = model('ActivityModel')
|
||||
->newActivity(
|
||||
'Create',
|
||||
$note->actor_id,
|
||||
$status->actor_id,
|
||||
null,
|
||||
$newNoteId,
|
||||
$newStatusId,
|
||||
$createActivity->toJSON(),
|
||||
$note->published_at,
|
||||
$status->published_at,
|
||||
'queued',
|
||||
);
|
||||
|
||||
$createActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId)));
|
||||
$createActivity->set('id', base_url(route_to('activity', $status->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
|
@ -306,44 +306,44 @@ class NoteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
Events::trigger('on_note_add', $note);
|
||||
Events::trigger('on_status_add', $status);
|
||||
|
||||
$this->clearCache($note);
|
||||
$this->clearCache($status);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $newNoteId;
|
||||
return $newStatusId;
|
||||
}
|
||||
|
||||
public function editNote(Note $updatedNote): bool
|
||||
public function editStatus(Status $updatedStatus): bool
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
// update note create activity schedule in database
|
||||
// update status create activity schedule in database
|
||||
$scheduledActivity = model('ActivityModel')
|
||||
->where([
|
||||
'type' => 'Create',
|
||||
'note_id' => $this->uuid
|
||||
->fromString($updatedNote->id)
|
||||
'status_id' => $this->uuid
|
||||
->fromString($updatedStatus->id)
|
||||
->getBytes(),
|
||||
])
|
||||
->first();
|
||||
|
||||
// update published date in payload
|
||||
$newPayload = $scheduledActivity->payload;
|
||||
$newPayload->object->published = $updatedNote->published_at->format(DATE_W3C);
|
||||
$newPayload->object->published = $updatedStatus->published_at->format(DATE_W3C);
|
||||
model('ActivityModel')
|
||||
->update($scheduledActivity->id, [
|
||||
'payload' => json_encode($newPayload, JSON_THROW_ON_ERROR),
|
||||
'scheduled_at' => $updatedNote->published_at,
|
||||
'scheduled_at' => $updatedStatus->published_at,
|
||||
]);
|
||||
|
||||
// update note
|
||||
$updateResult = $this->update($updatedNote->id, $updatedNote);
|
||||
// update status
|
||||
$updateResult = $this->update($updatedStatus->id, $updatedStatus);
|
||||
|
||||
Events::trigger('on_note_edit', $updatedNote);
|
||||
Events::trigger('on_status_edit', $updatedStatus);
|
||||
|
||||
$this->clearCache($updatedNote);
|
||||
$this->clearCache($updatedStatus);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
|
@ -351,59 +351,59 @@ class NoteModel extends UuidModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes a note from the database and decrements meta data
|
||||
* Removes a status from the database and decrements meta data
|
||||
*/
|
||||
public function removeNote(Note $note, bool $registerActivity = true): BaseResult | bool
|
||||
public function removeStatus(Status $status, bool $registerActivity = true): BaseResult | bool
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
model('ActorModel')
|
||||
->where('id', $note->actor_id)
|
||||
->decrement('notes_count');
|
||||
->where('id', $status->actor_id)
|
||||
->decrement('statuses_count');
|
||||
|
||||
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())
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
// Status to remove is a reply
|
||||
model('StatusModel')
|
||||
->where('id', $this->uuid->fromString($status->in_reply_to_id) ->getBytes())
|
||||
->decrement('replies_count');
|
||||
|
||||
Events::trigger('on_reply_remove', $note);
|
||||
Events::trigger('on_reply_remove', $status);
|
||||
}
|
||||
|
||||
// remove all note reblogs
|
||||
foreach ($note->reblogs as $reblog) {
|
||||
// remove all status reblogs
|
||||
foreach ($status->reblogs as $reblog) {
|
||||
// FIXME: issue when actor is not local, can't get actor information
|
||||
$this->removeNote($reblog);
|
||||
$this->removeStatus($reblog);
|
||||
}
|
||||
|
||||
// remove all note replies
|
||||
foreach ($note->replies as $reply) {
|
||||
$this->removeNote($reply);
|
||||
// remove all status replies
|
||||
foreach ($status->replies as $reply) {
|
||||
$this->removeStatus($reply);
|
||||
}
|
||||
|
||||
// check that preview card is no longer used elsewhere before deleting it
|
||||
if (
|
||||
$note->preview_card &&
|
||||
$status->preview_card &&
|
||||
$this->db
|
||||
->table('activitypub_notes_preview_cards')
|
||||
->where('preview_card_id', $note->preview_card->id)
|
||||
->table('activitypub_statuses_preview_cards')
|
||||
->where('preview_card_id', $status->preview_card->id)
|
||||
->countAll() <= 1
|
||||
) {
|
||||
model('PreviewCardModel')->deletePreviewCard($note->preview_card->id, $note->preview_card->url);
|
||||
model('PreviewCardModel')->deletePreviewCard($status->preview_card->id, $status->preview_card->url);
|
||||
}
|
||||
|
||||
if ($registerActivity) {
|
||||
$deleteActivity = new DeleteActivity();
|
||||
$tombstoneObject = new TombstoneObject();
|
||||
$tombstoneObject->set('id', $note->uri);
|
||||
$tombstoneObject->set('id', $status->uri);
|
||||
$deleteActivity
|
||||
->set('actor', $note->actor->uri)
|
||||
->set('actor', $status->actor->uri)
|
||||
->set('object', $tombstoneObject);
|
||||
|
||||
$activityId = model('ActivityModel')
|
||||
->newActivity(
|
||||
'Delete',
|
||||
$note->actor_id,
|
||||
$status->actor_id,
|
||||
null,
|
||||
null,
|
||||
$deleteActivity->toJSON(),
|
||||
|
@ -411,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', $status->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
|
@ -419,12 +419,12 @@ class NoteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
$result = model('NoteModel', false)
|
||||
->delete($note->id);
|
||||
$result = model('StatusModel', false)
|
||||
->delete($status->id);
|
||||
|
||||
Events::trigger('on_note_remove', $note);
|
||||
Events::trigger('on_status_remove', $status);
|
||||
|
||||
$this->clearCache($note);
|
||||
$this->clearCache($status);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
|
@ -432,38 +432,38 @@ class NoteModel extends UuidModel
|
|||
}
|
||||
|
||||
public function addReply(
|
||||
Note $reply,
|
||||
Status $reply,
|
||||
bool $createPreviewCard = true,
|
||||
bool $registerActivity = true
|
||||
): string | false {
|
||||
if (! $reply->in_reply_to_id) {
|
||||
throw new Exception('Passed note is not a reply!');
|
||||
throw new Exception('Passed status is not a reply!');
|
||||
}
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$noteId = $this->addNote($reply, $createPreviewCard, $registerActivity);
|
||||
$statusId = $this->addStatus($reply, $createPreviewCard, $registerActivity);
|
||||
|
||||
model('NoteModel')
|
||||
model('StatusModel')
|
||||
->where('id', $this->uuid->fromString($reply->in_reply_to_id) ->getBytes())
|
||||
->increment('replies_count');
|
||||
|
||||
Events::trigger('on_note_reply', $reply);
|
||||
Events::trigger('on_status_reply', $reply);
|
||||
|
||||
$this->clearCache($reply);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $noteId;
|
||||
return $statusId;
|
||||
}
|
||||
|
||||
public function reblog(Actor $actor, Note $note, bool $registerActivity = true): string | false
|
||||
public function reblog(Actor $actor, Status $status, bool $registerActivity = true): string | false
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$reblog = new Note([
|
||||
$reblog = new Status([
|
||||
'actor_id' => $actor->id,
|
||||
'reblog_of_id' => $note->id,
|
||||
'reblog_of_id' => $status->id,
|
||||
'published_at' => Time::now(),
|
||||
]);
|
||||
|
||||
|
@ -472,10 +472,10 @@ class NoteModel extends UuidModel
|
|||
|
||||
model('ActorModel')
|
||||
->where('id', $actor->id)
|
||||
->increment('notes_count');
|
||||
->increment('statuses_count');
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', $this->uuid->fromString($note->id)->getBytes())
|
||||
model('StatusModel')
|
||||
->where('id', $this->uuid->fromString($status->id)->getBytes())
|
||||
->increment('reblogs_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
|
@ -486,13 +486,13 @@ class NoteModel extends UuidModel
|
|||
'Announce',
|
||||
$actor->id,
|
||||
null,
|
||||
$note->id,
|
||||
$status->id,
|
||||
$announceActivity->toJSON(),
|
||||
$reblog->published_at,
|
||||
'queued',
|
||||
);
|
||||
|
||||
$announceActivity->set('id', base_url(route_to('activity', $note->actor->username, $activityId)));
|
||||
$announceActivity->set('id', base_url(route_to('activity', $status->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
|
@ -500,25 +500,25 @@ class NoteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
Events::trigger('on_note_reblog', $actor, $note);
|
||||
Events::trigger('on_status_reblog', $actor, $status);
|
||||
|
||||
$this->clearCache($note);
|
||||
$this->clearCache($status);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $reblogId;
|
||||
}
|
||||
|
||||
public function undoReblog(Note $reblogNote, bool $registerActivity = true): BaseResult | bool
|
||||
public function undoReblog(Status $reblogStatus, bool $registerActivity = true): BaseResult | bool
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
model('ActorModel')
|
||||
->where('id', $reblogNote->actor_id)
|
||||
->decrement('notes_count');
|
||||
->where('id', $reblogStatus->actor_id)
|
||||
->decrement('statuses_count');
|
||||
|
||||
model('NoteModel')
|
||||
->where('id', $this->uuid->fromString($reblogNote->reblog_of_id) ->getBytes())
|
||||
model('StatusModel')
|
||||
->where('id', $this->uuid->fromString($reblogStatus->reblog_of_id) ->getBytes())
|
||||
->decrement('reblogs_count');
|
||||
|
||||
if ($registerActivity) {
|
||||
|
@ -527,35 +527,35 @@ class NoteModel extends UuidModel
|
|||
$activity = model('ActivityModel')
|
||||
->where([
|
||||
'type' => 'Announce',
|
||||
'actor_id' => $reblogNote->actor_id,
|
||||
'note_id' => $this->uuid
|
||||
->fromString($reblogNote->reblog_of_id)
|
||||
'actor_id' => $reblogStatus->actor_id,
|
||||
'status_id' => $this->uuid
|
||||
->fromString($reblogStatus->reblog_of_id)
|
||||
->getBytes(),
|
||||
])
|
||||
->first();
|
||||
|
||||
$announceActivity = new AnnounceActivity($reblogNote);
|
||||
$announceActivity = new AnnounceActivity($reblogStatus);
|
||||
$announceActivity->set(
|
||||
'id',
|
||||
base_url(route_to('activity', $reblogNote->actor->username, $activity->id)),
|
||||
base_url(route_to('activity', $reblogStatus->actor->username, $activity->id)),
|
||||
);
|
||||
|
||||
$undoActivity
|
||||
->set('actor', $reblogNote->actor->uri)
|
||||
->set('actor', $reblogStatus->actor->uri)
|
||||
->set('object', $announceActivity);
|
||||
|
||||
$activityId = model('ActivityModel')
|
||||
->newActivity(
|
||||
'Undo',
|
||||
$reblogNote->actor_id,
|
||||
$reblogStatus->actor_id,
|
||||
null,
|
||||
$reblogNote->reblog_of_id,
|
||||
$reblogStatus->reblog_of_id,
|
||||
$undoActivity->toJSON(),
|
||||
Time::now(),
|
||||
'queued',
|
||||
);
|
||||
|
||||
$undoActivity->set('id', base_url(route_to('activity', $reblogNote->actor->username, $activityId)));
|
||||
$undoActivity->set('id', base_url(route_to('activity', $reblogStatus->actor->username, $activityId)));
|
||||
|
||||
model('ActivityModel')
|
||||
->update($activityId, [
|
||||
|
@ -563,54 +563,54 @@ class NoteModel extends UuidModel
|
|||
]);
|
||||
}
|
||||
|
||||
$result = model('NoteModel', false)
|
||||
->delete($reblogNote->id);
|
||||
$result = model('StatusModel', false)
|
||||
->delete($reblogStatus->id);
|
||||
|
||||
Events::trigger('on_note_undo_reblog', $reblogNote);
|
||||
Events::trigger('on_status_undo_reblog', $reblogStatus);
|
||||
|
||||
$this->clearCache($reblogNote);
|
||||
$this->clearCache($reblogStatus);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function toggleReblog(Actor $actor, Note $note): void
|
||||
public function toggleReblog(Actor $actor, Status $status): void
|
||||
{
|
||||
if (
|
||||
! ($reblogNote = $this->where([
|
||||
! ($reblogStatus = $this->where([
|
||||
'actor_id' => $actor->id,
|
||||
'reblog_of_id' => $this->uuid
|
||||
->fromString($note->id)
|
||||
->fromString($status->id)
|
||||
->getBytes(),
|
||||
])->first())
|
||||
) {
|
||||
$this->reblog($actor, $note);
|
||||
$this->reblog($actor, $status);
|
||||
} else {
|
||||
$this->undoReblog($reblogNote);
|
||||
$this->undoReblog($reblogStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearCache(Note $note): void
|
||||
public function clearCache(Status $status): void
|
||||
{
|
||||
$cachePrefix = config('ActivityPub')
|
||||
->cachePrefix;
|
||||
|
||||
$hashedNoteUri = md5($note->uri);
|
||||
$hashedStatusUri = md5($status->uri);
|
||||
|
||||
model('ActorModel')
|
||||
->clearCache($note->actor);
|
||||
->clearCache($status->actor);
|
||||
cache()
|
||||
->deleteMatching($cachePrefix . "note#{$note->id}*");
|
||||
->deleteMatching($cachePrefix . "status#{$status->id}*");
|
||||
cache()
|
||||
->deleteMatching($cachePrefix . "note-{$hashedNoteUri}*");
|
||||
->deleteMatching($cachePrefix . "status-{$hashedStatusUri}*");
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$this->clearCache($note->reply_to_note);
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
$this->clearCache($status->reply_to_status);
|
||||
}
|
||||
|
||||
if ($note->reblog_of_id !== null) {
|
||||
$this->clearCache($note->reblog_of_note);
|
||||
if ($status->reblog_of_id !== null) {
|
||||
$this->clearCache($status->reblog_of_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@ class NoteModel extends UuidModel
|
|||
* @param array<string, array<string|int, mixed>> $data
|
||||
* @return array<string, array<string|int, mixed>>
|
||||
*/
|
||||
protected function setNoteId(array $data): array
|
||||
protected function setStatusId(array $data): array
|
||||
{
|
||||
$uuid4 = $this->uuid->{$this->uuidVersion}();
|
||||
$data['data']['id'] = $uuid4->toString();
|
||||
|
@ -627,7 +627,7 @@ class NoteModel extends UuidModel
|
|||
$actor = model('ActorModel')
|
||||
->getActorById((int) $data['data']['actor_id']);
|
||||
|
||||
$data['data']['uri'] = base_url(route_to('note', $actor->username, $uuid4->toString()));
|
||||
$data['data']['uri'] = base_url(route_to('status', $actor->username, $uuid4->toString()));
|
||||
}
|
||||
|
||||
return $data;
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace ActivityPub\Objects;
|
||||
|
||||
use ActivityPub\Core\ObjectType;
|
||||
use ActivityPub\Entities\Note;
|
||||
use ActivityPub\Entities\Status;
|
||||
|
||||
class NoteObject extends ObjectType
|
||||
{
|
||||
|
@ -27,20 +27,20 @@ class NoteObject extends ObjectType
|
|||
|
||||
protected string $replies;
|
||||
|
||||
public function __construct(Note $note)
|
||||
public function __construct(Status $status)
|
||||
{
|
||||
$this->id = $note->uri;
|
||||
$this->id = $status->uri;
|
||||
|
||||
$this->content = $note->message_html;
|
||||
$this->published = $note->published_at->format(DATE_W3C);
|
||||
$this->attributedTo = $note->actor->uri;
|
||||
$this->content = $status->message_html;
|
||||
$this->published = $status->published_at->format(DATE_W3C);
|
||||
$this->attributedTo = $status->actor->uri;
|
||||
|
||||
if ($note->in_reply_to_id !== null) {
|
||||
$this->inReplyTo = $note->reply_to_note->uri;
|
||||
if ($status->in_reply_to_id !== null) {
|
||||
$this->inReplyTo = $status->reply_to_status->uri;
|
||||
}
|
||||
|
||||
$this->replies = base_url(route_to('note-replies', $note->actor->username, $note->id));
|
||||
$this->replies = base_url(route_to('status-replies', $status->actor->username, $status->id));
|
||||
|
||||
$this->cc = [$note->actor->followers_url];
|
||||
$this->cc = [$status->actor->followers_url];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,25 +11,25 @@ declare(strict_types=1);
|
|||
namespace App\Libraries;
|
||||
|
||||
use ActivityPub\Objects\NoteObject as ActivityPubNoteObject;
|
||||
use App\Entities\Note;
|
||||
use App\Entities\Status;
|
||||
|
||||
class NoteObject extends ActivityPubNoteObject
|
||||
{
|
||||
/**
|
||||
* @param Note $note
|
||||
* @param Status $status
|
||||
*/
|
||||
public function __construct($note)
|
||||
public function __construct($status)
|
||||
{
|
||||
parent::__construct($note);
|
||||
parent::__construct($status);
|
||||
|
||||
if ($note->episode_id) {
|
||||
if ($status->episode_id) {
|
||||
$this->content =
|
||||
'<a href="' .
|
||||
$note->episode->link .
|
||||
$status->episode->link .
|
||||
'" target="_blank" rel="noopener noreferrer">' .
|
||||
$note->episode->title .
|
||||
$status->episode->title .
|
||||
'</a><br/>' .
|
||||
$note->message_html;
|
||||
$status->message_html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class EpisodeModel extends Model
|
|||
'custom_rss',
|
||||
'favourites_total',
|
||||
'reblogs_total',
|
||||
'notes_total',
|
||||
'statuses_total',
|
||||
'published_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
|
|
|
@ -10,15 +10,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use ActivityPub\Models\NoteModel as ActivityPubNoteModel;
|
||||
use App\Entities\Note;
|
||||
use ActivityPub\Models\StatusModel as ActivityPubStatusModel;
|
||||
use App\Entities\Status;
|
||||
|
||||
class NoteModel extends ActivityPubNoteModel
|
||||
class StatusModel extends ActivityPubStatusModel
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $returnType = Note::class;
|
||||
protected $returnType = Status::class;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
|
@ -40,11 +40,11 @@ class NoteModel extends ActivityPubNoteModel
|
|||
];
|
||||
|
||||
/**
|
||||
* Retrieves all published notes for a given episode ordered by publication date
|
||||
* Retrieves all published statuses for a given episode ordered by publication date
|
||||
*
|
||||
* @return Note[]
|
||||
* @return Status[]
|
||||
*/
|
||||
public function getEpisodeNotes(int $episodeId): array
|
||||
public function getEpisodeStatuses(int $episodeId): array
|
||||
{
|
||||
return $this->where([
|
||||
'episode_id' => $episodeId,
|
|
@ -7,7 +7,7 @@
|
|||
@import "./radioBtn.css";
|
||||
@import "./switch.css";
|
||||
@import "./charts.css";
|
||||
@import "./note.css";
|
||||
@import "./status.css";
|
||||
@import "./tabs.css";
|
||||
@import "./radioToggler.css";
|
||||
@import "./formInputTabs.css";
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
@layer components {
|
||||
.note-content {
|
||||
.status-content {
|
||||
& a {
|
||||
@apply text-sm font-semibold text-pine-600 hover:underline;
|
||||
}
|
||||
}
|
||||
|
||||
.note-replies > * {
|
||||
.status-replies > * {
|
||||
@apply relative;
|
||||
|
||||
& img {
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
|
||||
<label for="message" class="text-lg font-semibold"><?= lang(
|
||||
'Episode.publish_form.note',
|
||||
) . hint_tooltip(lang('Episode.publish_form.note_hint'), 'ml-1') ?></label>
|
||||
'Episode.publish_form.status',
|
||||
) . hint_tooltip(lang('Episode.publish_form.status_hint'), 'ml-1') ?></label>
|
||||
<div class="mb-8 overflow-hidden bg-white shadow-md rounded-xl">
|
||||
<div class="flex px-4 py-3">
|
||||
<img src="<?= $podcast->actor->avatar_image_url ?>" alt="<?= $podcast
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
]) ?>
|
||||
<?= csrf_field() ?>
|
||||
<?= form_hidden('client_timezone', 'UTC') ?>
|
||||
<?= form_hidden('note_id', $note->id) ?>
|
||||
<?= form_hidden('status_id', $status->id) ?>
|
||||
|
||||
|
||||
<label for="message" class="text-lg font-semibold"><?= lang(
|
||||
'Episode.publish_form.note',
|
||||
) . hint_tooltip(lang('Episode.publish_form.note_hint'), 'ml-1') ?></label>
|
||||
'Episode.publish_form.status',
|
||||
) . hint_tooltip(lang('Episode.publish_form.status_hint'), 'ml-1') ?></label>
|
||||
<div class="mb-8 overflow-hidden bg-white shadow-md rounded-xl">
|
||||
<div class="flex px-4 py-3">
|
||||
<img src="<?= $podcast->actor->avatar_image_url ?>" alt="<?= $podcast->actor
|
||||
|
@ -34,11 +34,11 @@
|
|||
<span class="text-sm text-gray-500 truncate">@<?= $podcast
|
||||
->actor->username ?></span>
|
||||
</p>
|
||||
<time class="text-xs text-gray-500" itemprop="published" datetime="<?= $note->published_at->format(
|
||||
<time class="text-xs text-gray-500" itemprop="published" datetime="<?= $status->published_at->format(
|
||||
DateTime::ATOM,
|
||||
) ?>" title="<?= $note->published_at ?>"><?= lang(
|
||||
) ?>" title="<?= $status->published_at ?>"><?= lang(
|
||||
'Common.mediumDate',
|
||||
[$note->published_at],
|
||||
[$status->published_at],
|
||||
) ?></time>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,7 +51,7 @@
|
|||
'required' => 'required',
|
||||
'placeholder' => 'Write your message...',
|
||||
],
|
||||
old('message', $note->message, false),
|
||||
old('message', $status->message, false),
|
||||
['rows' => 2],
|
||||
) ?>
|
||||
</div>
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<a href="<?= route_to(
|
||||
'podcast-activity',
|
||||
$podcast->name,
|
||||
) ?>" class="hover:underline"><?= lang('Podcast.notes', [
|
||||
'numberOfNotes' => $podcast->actor->notes_count,
|
||||
) ?>" class="hover:underline"><?= lang('Podcast.statuses', [
|
||||
'numberOfStatuses' => $podcast->actor->statuses_count,
|
||||
]) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<article class="relative z-10 w-full bg-white shadow-md rounded-2xl">
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $note->actor
|
||||
->avatar_image_url ?>" alt="<?= $note->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $note->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $note
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $note->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $note->actor
|
||||
->username .
|
||||
($note->actor->is_local
|
||||
? ''
|
||||
: '@' . $note->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('note', $podcast->name, $note->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $note->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $note->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$note->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 note-content"><?= $note->message_html ?></div>
|
||||
<?php if ($note->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $note->episode,
|
||||
]) ?>
|
||||
<?php elseif ($note->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $note->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/note_actions') ?>
|
||||
</article>
|
|
@ -1,36 +0,0 @@
|
|||
<footer class="flex justify-around px-6 py-3">
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $note->id),
|
||||
icon('chat', 'text-2xl mr-1 text-gray-400') . $note->replies_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'title' => lang('Note.replies', [
|
||||
'numberOfReplies' => $note->replies_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('note-remote-action', $podcast->name, $note->id, 'reblog'),
|
||||
icon('repeat', 'text-2xl mr-1 text-gray-400') . $note->reblogs_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Note.reblogs', [
|
||||
'numberOfReblogs' => $note->reblogs_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('note-remote-action', $podcast->name, $note->id, 'favourite'),
|
||||
icon('heart', 'text-2xl mr-1 text-gray-400') . $note->favourites_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Note.favourites', [
|
||||
'numberOfFavourites' => $note->favourites_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
</footer>
|
|
@ -1,40 +0,0 @@
|
|||
<article class="relative z-10 w-full bg-white shadow-md rounded-2xl">
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $note->actor
|
||||
->avatar_image_url ?>" alt="<?= $note->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $note->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $note
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $note->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $note->actor
|
||||
->username .
|
||||
($note->actor->is_local
|
||||
? ''
|
||||
: '@' . $note->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('note', $podcast->name, $note->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $note->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $note->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$note->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 note-content"><?= $note->message_html ?></div>
|
||||
<?php if ($note->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $note->episode,
|
||||
]) ?>
|
||||
<?php elseif ($note->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $note->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/note_actions_authenticated') ?>
|
||||
</article>
|
|
@ -3,45 +3,45 @@
|
|||
'repeat',
|
||||
'text-lg mr-2 text-gray-400',
|
||||
) .
|
||||
lang('Note.actor_shared', [
|
||||
'actor' => $note->actor->display_name,
|
||||
lang('Status.actor_shared', [
|
||||
'actor' => $status->actor->display_name,
|
||||
]) ?></p>
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $note->actor
|
||||
->avatar_image_url ?>" alt="<?= $note->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<img src="<?= $status->actor
|
||||
->avatar_image_url ?>" alt="<?= $status->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $note->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $note
|
||||
<a href="<?= $status->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $status
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $note->actor
|
||||
<span class="mr-2 font-semibold truncate"><?= $status->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $note->actor
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $status->actor
|
||||
->username .
|
||||
($note->actor->is_local
|
||||
($status->actor->is_local
|
||||
? ''
|
||||
: '@' . $note->actor->domain) ?></span>
|
||||
: '@' . $status->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('note', $podcast->name, $note->id) ?>"
|
||||
<a href="<?= route_to('status', $podcast->name, $status->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $note->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $note->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$note->published_at]) ?></time>
|
||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $status->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 note-content"><?= $note->message_html ?></div>
|
||||
<?php if ($note->episode_id): ?>
|
||||
<div class="px-6 mb-4 status-content"><?= $status->message_html ?></div>
|
||||
<?php if ($status->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $note->episode,
|
||||
'episode' => $status->episode,
|
||||
]) ?>
|
||||
<?php elseif ($note->has_preview_card): ?>
|
||||
<?php elseif ($status->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $note->preview_card,
|
||||
'preview_card' => $status->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/note_actions') ?>
|
||||
<?= $this->include('podcast/_partials/status_actions') ?>
|
||||
</article>
|
||||
|
|
|
@ -3,45 +3,45 @@
|
|||
'repeat',
|
||||
'text-lg mr-2 text-gray-400',
|
||||
) .
|
||||
lang('Note.actor_shared', [
|
||||
'actor' => $note->actor->display_name,
|
||||
lang('Status.actor_shared', [
|
||||
'actor' => $status->actor->display_name,
|
||||
]) ?></p>
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $note->actor
|
||||
->avatar_image_url ?>" alt="<?= $note->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<img src="<?= $status->actor
|
||||
->avatar_image_url ?>" alt="<?= $status->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $note->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $note
|
||||
<a href="<?= $status->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $status
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $note->actor
|
||||
<span class="mr-2 font-semibold truncate"><?= $status->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $note->actor
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $status->actor
|
||||
->username .
|
||||
($note->actor->is_local
|
||||
($status->actor->is_local
|
||||
? ''
|
||||
: '@' . $note->actor->domain) ?></span>
|
||||
: '@' . $status->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('note', $podcast->name, $note->id) ?>"
|
||||
<a href="<?= route_to('status', $podcast->name, $status->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $note->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $note->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$note->published_at]) ?></time>
|
||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $status->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 note-content"><?= $note->message_html ?></div>
|
||||
<?php if ($note->episode_id): ?>
|
||||
<div class="px-6 mb-4 status-content"><?= $status->message_html ?></div>
|
||||
<?php if ($status->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $note->episode,
|
||||
'episode' => $status->episode,
|
||||
]) ?>
|
||||
<?php elseif ($note->has_preview_card): ?>
|
||||
<?php elseif ($status->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $note->preview_card,
|
||||
'preview_card' => $status->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/note_actions_authenticated') ?>
|
||||
<?= $this->include('podcast/_partials/status_actions_authenticated') ?>
|
||||
</article>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
title="<?= $reply->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$reply->published_at]) ?></time>
|
||||
</header>
|
||||
<p class="mb-2 note-content"><?= $reply->message_html ?></p>
|
||||
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
||||
<?php if ($reply->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $reply->preview_card,
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
<footer class="mt-2 space-x-6 text-sm">
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $reply->id),
|
||||
route_to('status', $podcast->name, $reply->id),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') . $reply->replies_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'title' => lang('Note.replies', [
|
||||
'title' => lang('Status.replies', [
|
||||
'numberOfReplies' => $reply->replies_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('note-remote-action', $podcast->name, $reply->id, 'reblog'),
|
||||
route_to('status-remote-action', $podcast->name, $reply->id, 'reblog'),
|
||||
icon('repeat', 'text-xl mr-1 text-gray-400') . $reply->reblogs_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Note.reblogs', [
|
||||
'title' => lang('Status.reblogs', [
|
||||
'numberOfReblogs' => $reply->reblogs_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('note-remote-action', $podcast->name, $reply->id, 'favourite'),
|
||||
route_to('status-remote-action', $podcast->name, $reply->id, 'favourite'),
|
||||
icon('heart', 'text-xl mr-1 text-gray-400') . $reply->favourites_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Note.favourites', [
|
||||
'title' => lang('Status.favourites', [
|
||||
'numberOfFavourites' => $reply->favourites_count,
|
||||
]),
|
||||
],
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
<footer class="mt-2 text-sm">
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-action',
|
||||
'status-attempt-action',
|
||||
interact_as_actor()->username,
|
||||
$reply->id,
|
||||
) ?>" method="POST" class="flex items-start">
|
||||
<?= csrf_field() ?>
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $reply->id),
|
||||
route_to('status', $podcast->name, $reply->id),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') . $reply->replies_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center mr-6 hover:underline',
|
||||
'title' => lang('Note.replies', [
|
||||
'title' => lang('Status.replies', [
|
||||
'numberOfReplies' => $reply->replies_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<button type="submit" name="action" value="reblog" class="inline-flex items-center mr-6 hover:underline" title="<?= lang(
|
||||
'Note.reblogs',
|
||||
'Status.reblogs',
|
||||
[
|
||||
'numberOfReblogs' => $reply->reblogs_count,
|
||||
],
|
||||
) ?>"><?= icon('repeat', 'text-xl mr-1 text-gray-400') .
|
||||
$reply->reblogs_count ?></button>
|
||||
<button type="submit" name="action" value="favourite" class="inline-flex items-center mr-6 hover:underline" title="<?= lang(
|
||||
'Note.favourites',
|
||||
'Status.favourites',
|
||||
[
|
||||
'numberOfFavourites' => $reply->favourites_count,
|
||||
],
|
||||
|
@ -40,33 +40,33 @@
|
|||
'-more-dropdown-menu' ?>" class="flex flex-col py-2 text-sm bg-white border rounded-lg shadow" aria-labelledby="<?= $reply->id .
|
||||
'-more-dropdown' ?>" data-dropdown="menu" data-dropdown-placement="bottom">
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $reply->id),
|
||||
lang('Note.expand'),
|
||||
route_to('status', $podcast->name, $reply->id),
|
||||
lang('Status.expand'),
|
||||
[
|
||||
'class' => 'px-4 py-1 hover:bg-gray-100',
|
||||
],
|
||||
) ?>
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-block-actor',
|
||||
'status-attempt-block-actor',
|
||||
interact_as_actor()->username,
|
||||
$reply->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 text-left hover:bg-gray-100"><?= lang(
|
||||
'Note.block_actor',
|
||||
'Status.block_actor',
|
||||
[
|
||||
'actorUsername' => $reply->actor->username,
|
||||
],
|
||||
) ?></button>
|
||||
</form>
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-block-domain',
|
||||
'status-attempt-block-domain',
|
||||
interact_as_actor()->username,
|
||||
$reply->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 text-left hover:bg-gray-100"><?= lang(
|
||||
'Note.block_domain',
|
||||
'Status.block_domain',
|
||||
[
|
||||
'actorDomain' => $reply->actor->domain,
|
||||
],
|
||||
|
@ -75,13 +75,13 @@
|
|||
<?php if ($reply->actor->is_local): ?>
|
||||
<hr class="my-2" />
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-delete',
|
||||
'status-attempt-delete',
|
||||
$reply->actor->username,
|
||||
$reply->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 font-semibold text-left text-red-600 hover:bg-gray-100"><?= lang(
|
||||
'Note.delete',
|
||||
'Status.delete',
|
||||
) ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
title="<?= $reply->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$reply->published_at]) ?></time>
|
||||
</header>
|
||||
<p class="mb-2 note-content"><?= $reply->message_html ?></p>
|
||||
<p class="mb-2 status-content"><?= $reply->message_html ?></p>
|
||||
<?php if ($reply->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $reply->preview_card,
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<article class="relative z-10 w-full bg-white shadow-md rounded-2xl">
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $status->actor
|
||||
->avatar_image_url ?>" alt="<?= $status->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $status->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $status
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $status->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $status->actor
|
||||
->username .
|
||||
($status->actor->is_local
|
||||
? ''
|
||||
: '@' . $status->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('status', $podcast->name, $status->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $status->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 status-content"><?= $status->message_html ?></div>
|
||||
<?php if ($status->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $status->episode,
|
||||
]) ?>
|
||||
<?php elseif ($status->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $status->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/status_actions') ?>
|
||||
</article>
|
|
@ -0,0 +1,36 @@
|
|||
<footer class="flex justify-around px-6 py-3">
|
||||
<?= anchor(
|
||||
route_to('status', $podcast->name, $status->id),
|
||||
icon('chat', 'text-2xl mr-1 text-gray-400') . $status->replies_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'title' => lang('Status.replies', [
|
||||
'numberOfReplies' => $status->replies_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('status-remote-action', $podcast->name, $status->id, 'reblog'),
|
||||
icon('repeat', 'text-2xl mr-1 text-gray-400') . $status->reblogs_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Status.reblogs', [
|
||||
'numberOfReblogs' => $status->reblogs_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<?= anchor_popup(
|
||||
route_to('status-remote-action', $podcast->name, $status->id, 'favourite'),
|
||||
icon('heart', 'text-2xl mr-1 text-gray-400') . $status->favourites_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'width' => 420,
|
||||
'height' => 620,
|
||||
'title' => lang('Status.favourites', [
|
||||
'numberOfFavourites' => $status->favourites_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
</footer>
|
|
@ -1,87 +1,87 @@
|
|||
<footer class="px-6 py-3">
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-action',
|
||||
'status-attempt-action',
|
||||
interact_as_actor()->username,
|
||||
$note->id,
|
||||
$status->id,
|
||||
) ?>" method="POST" class="flex justify-around">
|
||||
<?= csrf_field() ?>
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $note->id),
|
||||
icon('chat', 'text-2xl mr-1 text-gray-400') . $note->replies_count,
|
||||
route_to('status', $podcast->name, $status->id),
|
||||
icon('chat', 'text-2xl mr-1 text-gray-400') . $status->replies_count,
|
||||
[
|
||||
'class' => 'inline-flex items-center hover:underline',
|
||||
'title' => lang('Note.replies', [
|
||||
'numberOfReplies' => $note->replies_count,
|
||||
'title' => lang('Status.replies', [
|
||||
'numberOfReplies' => $status->replies_count,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
<button type="submit" name="action" value="reblog" class="inline-flex items-center hover:underline" title="<?= lang(
|
||||
'Note.reblogs',
|
||||
'Status.reblogs',
|
||||
[
|
||||
'numberOfReblogs' => $note->reblogs_count,
|
||||
'numberOfReblogs' => $status->reblogs_count,
|
||||
],
|
||||
) ?>"><?= icon('repeat', 'text-2xl mr-1 text-gray-400') .
|
||||
$note->reblogs_count ?></button>
|
||||
$status->reblogs_count ?></button>
|
||||
<button type="submit" name="action" value="favourite" class="inline-flex items-center hover:underline" title="<?= lang(
|
||||
'Note.favourites',
|
||||
'Status.favourites',
|
||||
[
|
||||
'numberOfFavourites' => $note->favourites_count,
|
||||
'numberOfFavourites' => $status->favourites_count,
|
||||
],
|
||||
) ?>"><?= icon('heart', 'text-2xl mr-1 text-gray-400') .
|
||||
$note->favourites_count ?></button>
|
||||
<button id="<?= $note->id .
|
||||
'-more-dropdown' ?>" type="button" class="px-2 py-1 text-2xl text-gray-500 outline-none focus:ring" data-dropdown="button" data-dropdown-target="<?= $note->id .
|
||||
$status->favourites_count ?></button>
|
||||
<button id="<?= $status->id .
|
||||
'-more-dropdown' ?>" type="button" class="px-2 py-1 text-2xl text-gray-500 outline-none focus:ring" data-dropdown="button" data-dropdown-target="<?= $status->id .
|
||||
'-more-dropdown-menu' ?>" aria-label="<?= lang(
|
||||
'Common.more',
|
||||
) ?>" aria-haspopup="true" aria-expanded="false"><?= icon('more') ?>
|
||||
</button>
|
||||
</form>
|
||||
<nav id="<?= $note->id .
|
||||
'-more-dropdown-menu' ?>" class="flex flex-col py-2 text-sm bg-white border rounded-lg shadow" aria-labelledby="<?= $note->id .
|
||||
<nav id="<?= $status->id .
|
||||
'-more-dropdown-menu' ?>" class="flex flex-col py-2 text-sm bg-white border rounded-lg shadow" aria-labelledby="<?= $status->id .
|
||||
'-more-dropdown' ?>" data-dropdown="menu" data-dropdown-placement="bottom">
|
||||
<?= anchor(
|
||||
route_to('note', $podcast->name, $note->id),
|
||||
lang('Note.expand'),
|
||||
route_to('status', $podcast->name, $status->id),
|
||||
lang('Status.expand'),
|
||||
[
|
||||
'class' => 'px-4 py-1 hover:bg-gray-100',
|
||||
],
|
||||
) ?>
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-block-actor',
|
||||
'status-attempt-block-actor',
|
||||
interact_as_actor()->username,
|
||||
$note->id,
|
||||
$status->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 text-left hover:bg-gray-100"><?= lang(
|
||||
'Note.block_actor',
|
||||
'Status.block_actor',
|
||||
[
|
||||
'actorUsername' => $note->actor->username,
|
||||
'actorUsername' => $status->actor->username,
|
||||
],
|
||||
) ?></button>
|
||||
</form>
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-block-domain',
|
||||
'status-attempt-block-domain',
|
||||
interact_as_actor()->username,
|
||||
$note->id,
|
||||
$status->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 text-left hover:bg-gray-100"><?= lang(
|
||||
'Note.block_domain',
|
||||
'Status.block_domain',
|
||||
[
|
||||
'actorDomain' => $note->actor->domain,
|
||||
'actorDomain' => $status->actor->domain,
|
||||
],
|
||||
) ?></button>
|
||||
</form>
|
||||
<?php if ($note->actor->is_local): ?>
|
||||
<?php if ($status->actor->is_local): ?>
|
||||
<hr class="my-2" />
|
||||
<form action="<?= route_to(
|
||||
'note-attempt-delete',
|
||||
$note->actor->username,
|
||||
$note->id,
|
||||
'status-attempt-delete',
|
||||
$status->actor->username,
|
||||
$status->id,
|
||||
) ?>" method="POST">
|
||||
<?= csrf_field() ?>
|
||||
<button class="w-full px-4 py-1 font-semibold text-left text-red-600 hover:bg-gray-100"><?= lang(
|
||||
'Note.delete',
|
||||
'Status.delete',
|
||||
) ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
|
@ -0,0 +1,40 @@
|
|||
<article class="relative z-10 w-full bg-white shadow-md rounded-2xl">
|
||||
<header class="flex px-6 py-4">
|
||||
<img src="<?= $status->actor
|
||||
->avatar_image_url ?>" alt="<?= $status->display_name ?>" class="w-12 h-12 mr-4 rounded-full" />
|
||||
<div class="flex flex-col min-w-0">
|
||||
<a href="<?= $status->actor
|
||||
->uri ?>" class="flex items-baseline hover:underline" <?= $status
|
||||
->actor->is_local
|
||||
? ''
|
||||
: 'target="_blank" rel="noopener noreferrer"' ?>>
|
||||
<span class="mr-2 font-semibold truncate"><?= $status->actor
|
||||
->display_name ?></span>
|
||||
<span class="text-sm text-gray-500 truncate">@<?= $status->actor
|
||||
->username .
|
||||
($status->actor->is_local
|
||||
? ''
|
||||
: '@' . $status->actor->domain) ?></span>
|
||||
</a>
|
||||
<a href="<?= route_to('status', $podcast->name, $status->id) ?>"
|
||||
class="text-xs text-gray-500">
|
||||
<time
|
||||
itemprop="published"
|
||||
datetime="<?= $status->published_at->format(DateTime::ATOM) ?>"
|
||||
title="<?= $status->published_at ?>"
|
||||
><?= lang('Common.mediumDate', [$status->published_at]) ?></time>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="px-6 mb-4 status-content"><?= $status->message_html ?></div>
|
||||
<?php if ($status->episode_id): ?>
|
||||
<?= view('podcast/_partials/episode_card', [
|
||||
'episode' => $status->episode,
|
||||
]) ?>
|
||||
<?php elseif ($status->has_preview_card): ?>
|
||||
<?= view('podcast/_partials/preview_card', [
|
||||
'preview_card' => $status->preview_card,
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->include('podcast/_partials/status_actions_authenticated') ?>
|
||||
</article>
|
|
@ -1,10 +1,10 @@
|
|||
<?= $this->include('podcast/_partials/note') ?>
|
||||
<div class="-mt-2 overflow-hidden border-b border-l border-r note-replies rounded-b-xl">
|
||||
<?= $this->include('podcast/_partials/status') ?>
|
||||
<div class="-mt-2 overflow-hidden border-b border-l border-r status-replies rounded-b-xl">
|
||||
|
||||
<div class="px-6 pt-8 pb-4 bg-gray-50">
|
||||
<?= anchor_popup(
|
||||
route_to('note-remote-action', $podcast->name, $note->id, 'reply'),
|
||||
lang('Note.reply_to', ['actorUsername' => $note->actor->username]),
|
||||
route_to('status-remote-action', $podcast->name, $status->id, 'reply'),
|
||||
lang('Status.reply_to', ['actorUsername' => $status->actor->username]),
|
||||
[
|
||||
'class' =>
|
||||
'text-center justify-center font-semibold rounded-full shadow relative z-10 px-4 py-2 w-full bg-rose-600 text-white inline-flex items-center hover:bg-rose-700',
|
||||
|
@ -15,8 +15,8 @@
|
|||
</div>
|
||||
|
||||
|
||||
<?php if ($note->has_replies): ?>
|
||||
<?php foreach ($note->replies as $reply): ?>
|
||||
<?php if ($status->has_replies): ?>
|
||||
<?php foreach ($status->replies as $reply): ?>
|
||||
<?= view('podcast/_partials/reply', ['reply' => $reply]) ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
|
@ -1,7 +1,7 @@
|
|||
<?= $this->include('podcast/_partials/note_authenticated') ?>
|
||||
<div class="-mt-2 overflow-hidden border-b border-l border-r note-replies rounded-b-xl">
|
||||
<?= $this->include('podcast/_partials/status_authenticated') ?>
|
||||
<div class="-mt-2 overflow-hidden border-b border-l border-r status-replies rounded-b-xl">
|
||||
<?= form_open(
|
||||
route_to('note-attempt-action', interact_as_actor()->username, $note->id),
|
||||
route_to('status-attempt-action', interact_as_actor()->username, $status->id),
|
||||
[
|
||||
'class' => 'bg-gray-50 flex px-6 pt-8 pb-4',
|
||||
],
|
||||
|
@ -16,8 +16,8 @@
|
|||
'name' => 'message',
|
||||
'class' => 'form-textarea mb-4 w-full',
|
||||
'required' => 'required',
|
||||
'placeholder' => lang('Note.form.reply_to_placeholder', [
|
||||
'actorUsername' => $note->actor->username,
|
||||
'placeholder' => lang('Status.form.reply_to_placeholder', [
|
||||
'actorUsername' => $status->actor->username,
|
||||
]),
|
||||
],
|
||||
old('message', '', false),
|
||||
|
@ -26,7 +26,7 @@
|
|||
],
|
||||
) ?>
|
||||
<?= button(
|
||||
lang('Note.form.submit_reply'),
|
||||
lang('Status.form.submit_reply'),
|
||||
'',
|
||||
['variant' => 'primary', 'size' => 'small'],
|
||||
[
|
||||
|
@ -39,8 +39,8 @@
|
|||
</div>
|
||||
<?= form_close() ?>
|
||||
|
||||
<?php if ($note->has_replies): ?>
|
||||
<?php foreach ($note->replies as $reply): ?>
|
||||
<?php if ($status->has_replies): ?>
|
||||
<?php foreach ($status->replies as $reply): ?>
|
||||
<?= view('podcast/_partials/reply_authenticated', [
|
||||
'reply' => $reply,
|
||||
]) ?>
|
|
@ -39,13 +39,13 @@
|
|||
</nav>
|
||||
|
||||
<section class="max-w-2xl px-6 py-8 mx-auto space-y-8">
|
||||
<?php foreach ($notes as $note): ?>
|
||||
<?php if ($note->reblog_of_id !== null): ?>
|
||||
<?php foreach ($statuses as $status): ?>
|
||||
<?php if ($status->reblog_of_id !== null): ?>
|
||||
<?= view('podcast/_partials/reblog', [
|
||||
'note' => $note->reblog_of_note,
|
||||
'status' => $status->reblog_of_status,
|
||||
]) ?>
|
||||
<?php else: ?>
|
||||
<?= view('podcast/_partials/note', ['note' => $note]) ?>
|
||||
<?= view('podcast/_partials/status', ['status' => $status]) ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</nav>
|
||||
|
||||
<section class="max-w-2xl px-6 py-8 mx-auto">
|
||||
<?= form_open(route_to('note-attempt-create', interact_as_actor()->username), [
|
||||
<?= form_open(route_to('status-attempt-create', interact_as_actor()->username), [
|
||||
'class' => 'flex p-4 bg-white shadow rounded-xl',
|
||||
]) ?>
|
||||
<?= csrf_field() ?>
|
||||
|
@ -56,7 +56,7 @@
|
|||
'name' => 'message',
|
||||
'class' => 'form-textarea',
|
||||
'required' => 'required',
|
||||
'placeholder' => lang('Note.form.message_placeholder'),
|
||||
'placeholder' => lang('Status.form.message_placeholder'),
|
||||
],
|
||||
old('message', '', false),
|
||||
['rows' => 2],
|
||||
|
@ -66,7 +66,7 @@
|
|||
'name' => 'episode_url',
|
||||
'class' => 'form-input mb-2',
|
||||
'placeholder' =>
|
||||
lang('Note.form.episode_url_placeholder') .
|
||||
lang('Status.form.episode_url_placeholder') .
|
||||
' (' .
|
||||
lang('Common.optional') .
|
||||
')',
|
||||
|
@ -74,7 +74,7 @@
|
|||
]) ?>
|
||||
|
||||
<?= button(
|
||||
lang('Note.form.submit'),
|
||||
lang('Status.form.submit'),
|
||||
'',
|
||||
['variant' => 'primary', 'size' => 'small'],
|
||||
['type' => 'submit', 'class' => 'self-end'],
|
||||
|
@ -84,13 +84,13 @@
|
|||
<hr class="my-4 border-2 border-pine-100">
|
||||
|
||||
<div class="space-y-8">
|
||||
<?php foreach ($notes as $note): ?>
|
||||
<?php if ($note->reblog_of_id !== null): ?>
|
||||
<?php foreach ($statuses as $status): ?>
|
||||
<?php if ($status->reblog_of_id !== null): ?>
|
||||
<?= view('podcast/_partials/reblog_authenticated', [
|
||||
'note' => $note->reblog_of_note,
|
||||
'status' => $status->reblog_of_status,
|
||||
]) ?>
|
||||
<?php else: ?>
|
||||
<?= view('podcast/_partials/note_authenticated', ['note' => $note]) ?>
|
||||
<?= view('podcast/_partials/status_authenticated', ['status' => $status]) ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
|
|
@ -75,12 +75,12 @@
|
|||
<?= anchor(
|
||||
route_to('episode', $podcast->name, $episode->slug),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') .
|
||||
$episode->notes_total,
|
||||
$episode->statuses_total,
|
||||
[
|
||||
'class' =>
|
||||
'inline-flex items-center hover:underline',
|
||||
'title' => lang('Episode.total_notes', [
|
||||
'numberOfTotalNotes' => $episode->notes_total,
|
||||
'title' => lang('Episode.total_statuses', [
|
||||
'numberOfTotalStatuses' => $episode->statuses_total,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
|
@ -122,24 +122,24 @@
|
|||
</header>
|
||||
|
||||
<div class="tabset">
|
||||
<?php if ($episode->notes): ?>
|
||||
<?php if ($episode->statuses): ?>
|
||||
|
||||
<input type="radio" name="tabset" id="activity" aria-controls="activity" checked="checked" />
|
||||
<label for="activity"><?= lang('Episode.activity') ?></label>
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="radio" name="tabset" id="description" aria-controls="description" <?= $episode->notes
|
||||
<input type="radio" name="tabset" id="description" aria-controls="description" <?= $episode->statuses
|
||||
? ''
|
||||
: 'checked="checked"' ?> />
|
||||
<label for="description" class="<?= $episode->notes
|
||||
<label for="description" class="<?= $episode->statuses
|
||||
? ''
|
||||
: 'col-span-2' ?>"><?= lang('Episode.description') ?></label>
|
||||
|
||||
<div class="tab-panels">
|
||||
<?php if ($episode->notes): ?>
|
||||
<?php if ($episode->statuses): ?>
|
||||
<section id="activity" class="space-y-8 tab-panel">
|
||||
<?php foreach ($episode->notes as $note): ?>
|
||||
<?= view('podcast/_partials/note', ['note' => $note]) ?>
|
||||
<?php foreach ($episode->statuses as $status): ?>
|
||||
<?= view('podcast/_partials/status', ['status' => $status]) ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -75,12 +75,12 @@
|
|||
<?= anchor(
|
||||
route_to('episode', $podcast->name, $episode->slug),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') .
|
||||
$episode->notes_total,
|
||||
$episode->statuses_total,
|
||||
[
|
||||
'class' =>
|
||||
'inline-flex items-center hover:underline',
|
||||
'title' => lang('Episode.total_notes', [
|
||||
'numberOfTotalNotes' => $episode->notes_total,
|
||||
'title' => lang('Episode.total_statuses', [
|
||||
'numberOfTotalStatuses' => $episode->statuses_total,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
|
@ -130,7 +130,7 @@
|
|||
|
||||
<div class="tab-panels">
|
||||
<section id="activity" class="space-y-8 tab-panel">
|
||||
<?= form_open(route_to('note-attempt-create', $podcast->name), [
|
||||
<?= form_open(route_to('status-attempt-create', $podcast->name), [
|
||||
'class' => 'flex p-4 bg-white shadow rounded-xl',
|
||||
]) ?>
|
||||
<?= csrf_field() ?>
|
||||
|
@ -148,7 +148,7 @@
|
|||
'class' => 'form-textarea mb-2',
|
||||
'required' => 'required',
|
||||
'placeholder' => lang(
|
||||
'Note.form.episode_message_placeholder',
|
||||
'Status.form.episode_message_placeholder',
|
||||
),
|
||||
],
|
||||
old('message', '', false),
|
||||
|
@ -163,7 +163,7 @@
|
|||
'type' => 'hidden',
|
||||
]) ?>
|
||||
<?= button(
|
||||
lang('Note.form.submit'),
|
||||
lang('Status.form.submit'),
|
||||
'',
|
||||
['variant' => 'primary', 'size' => 'small'],
|
||||
['type' => 'submit', 'class' => 'self-end'],
|
||||
|
@ -171,9 +171,9 @@
|
|||
</div>
|
||||
<?= form_close() ?>
|
||||
<hr class="my-4 border border-pine-100">
|
||||
<?php foreach ($episode->notes as $note): ?>
|
||||
<?= view('podcast/_partials/note_authenticated', [
|
||||
'note' => $note,
|
||||
<?php foreach ($episode->statuses as $status): ?>
|
||||
<?= view('podcast/_partials/status_authenticated', [
|
||||
'status' => $status,
|
||||
]) ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
|
|
@ -121,12 +121,12 @@
|
|||
<?= anchor(
|
||||
route_to('episode', $podcast->name, $episode->slug),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') .
|
||||
$episode->notes_total,
|
||||
$episode->statuses_total,
|
||||
[
|
||||
'class' =>
|
||||
'inline-flex items-center hover:underline',
|
||||
'title' => lang('Episode.total_notes', [
|
||||
'numberOfTotalNotes' => $episode->notes_total,
|
||||
'title' => lang('Episode.total_statuses', [
|
||||
'numberOfTotalStatuses' => $episode->statuses_total,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
|
|
|
@ -121,12 +121,12 @@
|
|||
<?= anchor(
|
||||
route_to('episode', $podcast->name, $episode->slug),
|
||||
icon('chat', 'text-xl mr-1 text-gray-400') .
|
||||
$episode->notes_total,
|
||||
$episode->statuses_total,
|
||||
[
|
||||
'class' =>
|
||||
'inline-flex items-center hover:underline',
|
||||
'title' => lang('Episode.total_notes', [
|
||||
'numberOfTotalNotes' => $episode->notes_total,
|
||||
'title' => lang('Episode.total_statuses', [
|
||||
'numberOfTotalStatuses' => $episode->statuses_total,
|
||||
]),
|
||||
],
|
||||
) ?>
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?= $this->extend('podcast/_layout') ?>
|
||||
|
||||
<?= $this->section('meta-tags') ?>
|
||||
<title><?= lang('Note.title', [
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
]) ?></title>
|
||||
<meta name="description" content="<?= $note->message ?>"/>
|
||||
<meta property="og:title" content="<?= lang('Note.title', [
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
]) ?>"/>
|
||||
<meta property="og:locale" content="<?= service(
|
||||
'request',
|
||||
)->getLocale() ?>" />
|
||||
<meta property="og:site_name" content="<?= $note->actor->display_name ?>" />
|
||||
<meta property="og:url" content="<?= current_url() ?>" />
|
||||
<meta property="og:image" content="<?= $note->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $note->message ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="max-w-2xl px-6 mx-auto">
|
||||
<nav class="py-3">
|
||||
<a href="<?= route_to('podcast-activity', $podcast->name) ?>"
|
||||
class="inline-flex items-center px-4 py-2 text-sm"><?= icon(
|
||||
'arrow-left',
|
||||
'mr-2 text-lg',
|
||||
) .
|
||||
lang('Note.back_to_actor_notes', [
|
||||
'actor' => $note->actor->display_name,
|
||||
]) ?></a>
|
||||
</nav>
|
||||
<div class="pb-12">
|
||||
<?= $this->include('podcast/_partials/note_with_replies') ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->endSection()
|
||||
?>
|
|
@ -0,0 +1,38 @@
|
|||
<?= $this->extend('podcast/_layout') ?>
|
||||
|
||||
<?= $this->section('meta-tags') ?>
|
||||
<title><?= lang('Status.title', [
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
]) ?></title>
|
||||
<meta name="description" content="<?= $status->message ?>"/>
|
||||
<meta property="og:title" content="<?= lang('Status.title', [
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
]) ?>"/>
|
||||
<meta property="og:locale" content="<?= service(
|
||||
'request',
|
||||
)->getLocale() ?>" />
|
||||
<meta property="og:site_name" content="<?= $status->actor->display_name ?>" />
|
||||
<meta property="og:url" content="<?= current_url() ?>" />
|
||||
<meta property="og:image" content="<?= $status->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $status->message ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="max-w-2xl px-6 mx-auto">
|
||||
<nav class="py-3">
|
||||
<a href="<?= route_to('podcast-activity', $podcast->name) ?>"
|
||||
class="inline-flex items-center px-4 py-2 text-sm"><?= icon(
|
||||
'arrow-left',
|
||||
'mr-2 text-lg',
|
||||
) .
|
||||
lang('Status.back_to_actor_statuses', [
|
||||
'actor' => $status->actor->display_name,
|
||||
]) ?></a>
|
||||
</nav>
|
||||
<div class="pb-12">
|
||||
<?= $this->include('podcast/_partials/status_with_replies') ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->endSection()
|
||||
?>
|
|
@ -1,20 +1,20 @@
|
|||
<?= $this->extend('podcast/_layout_authenticated') ?>
|
||||
|
||||
<?= $this->section('meta-tags') ?>
|
||||
<title><?= lang('Note.title', [
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
<title><?= lang('Status.title', [
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
]) ?></title>
|
||||
<meta name="description" content="<?= $note->message ?>"/>
|
||||
<meta property="og:title" content="<?= lang('Note.title', [
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
<meta name="description" content="<?= $status->message ?>"/>
|
||||
<meta property="og:title" content="<?= lang('Status.title', [
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
]) ?>"/>
|
||||
<meta property="og:locale" content="<?= service(
|
||||
'request',
|
||||
)->getLocale() ?>" />
|
||||
<meta property="og:site_name" content="<?= $note->actor->display_name ?>" />
|
||||
<meta property="og:site_name" content="<?= $status->actor->display_name ?>" />
|
||||
<meta property="og:url" content="<?= current_url() ?>" />
|
||||
<meta property="og:image" content="<?= $note->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $note->message ?>" />
|
||||
<meta property="og:image" content="<?= $status->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $status->message ?>" />
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
|
@ -25,13 +25,13 @@
|
|||
'arrow-left',
|
||||
'mr-2 text-lg',
|
||||
) .
|
||||
lang('Note.back_to_actor_notes', [
|
||||
'actor' => $note->actor->display_name,
|
||||
lang('Status.back_to_actor_statuses', [
|
||||
'actor' => $status->actor->display_name,
|
||||
]) ?></a>
|
||||
</nav>
|
||||
<div class="pb-12">
|
||||
<?= $this->include(
|
||||
'podcast/_partials/note_with_replies_authenticated',
|
||||
'podcast/_partials/status_with_replies_authenticated',
|
||||
) ?>
|
||||
</div>
|
||||
</div>
|
|
@ -7,22 +7,22 @@
|
|||
<link rel="shortcut icon" type="image/png" href="/favicon.ico" />
|
||||
|
||||
<title><?= lang('ActivityPub.' . $action . '.title', [
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
]) ?></title>
|
||||
<meta name="description" content="<?= $note->message ?>"/>
|
||||
<meta name="description" content="<?= $status->message ?>"/>
|
||||
<meta property="og:title" content="<?= lang(
|
||||
'ActivityPub.' . $action . '.title',
|
||||
[
|
||||
'actorDisplayName' => $note->actor->display_name,
|
||||
'actorDisplayName' => $status->actor->display_name,
|
||||
],
|
||||
) ?>"/>
|
||||
<meta property="og:locale" content="<?= service(
|
||||
'request',
|
||||
)->getLocale() ?>" />
|
||||
<meta property="og:site_name" content="<?= $note->actor->display_name ?>" />
|
||||
<meta property="og:site_name" content="<?= $status->actor->display_name ?>" />
|
||||
<meta property="og:url" content="<?= current_url() ?>" />
|
||||
<meta property="og:image" content="<?= $note->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $note->message ?>" />
|
||||
<meta property="og:image" content="<?= $status->actor->avatar_image_url ?>" />
|
||||
<meta property="og:description" content="<?= $status->message ?>" />
|
||||
|
||||
<link rel="stylesheet" href="/assets/index.css"/>
|
||||
<script src="/assets/podcast.js" type="module"></script>
|
||||
|
@ -35,10 +35,10 @@
|
|||
) ?></h1>
|
||||
</header>
|
||||
<main class="flex-1 max-w-xl px-4 pb-8 mx-auto -mt-24">
|
||||
<?= $this->include('podcast/_partials/note') ?>
|
||||
<?= $this->include('podcast/_partials/status') ?>
|
||||
|
||||
<?= form_open(
|
||||
route_to('note-attempt-remote-action', $note->id, $action),
|
||||
route_to('status-attempt-remote-action', $status->id, $action),
|
||||
['method' => 'post', 'class' => 'flex flex-col mt-8'],
|
||||
) ?>
|
||||
<?= csrf_field() ?>
|
Loading…
Reference in New Issue