From 941cbe659972a297d8d0144ff36450b4a70e6fb9 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sat, 18 Sep 2021 03:22:27 +0100 Subject: [PATCH] [Actor] Refactor GSActor into Actor --- bin/generate_entity_diagrams | 2 +- bin/generate_entity_fields | 2 +- components/Avatar/Avatar.php | 52 +++++++++---------- components/Avatar/Controller/Avatar.php | 16 +++--- components/Avatar/Entity/Avatar.php | 16 +++--- components/Posting/Posting.php | 10 ++-- docs/developer/src/cache.md | 2 +- .../ActivityStreamsTwo/ActivityStreamsTwo.php | 8 +-- .../Util/Model/EntityToType/GSActorToType.php | 9 ++-- .../Util/Response/ActorResponse.php | 11 ++-- plugins/Cover/Controller/Cover.php | 8 +-- plugins/Cover/Cover.php | 2 +- plugins/Cover/Entity/Cover.php | 16 +++--- plugins/Directory/Controller/Directory.php | 2 +- plugins/Favourite/Controller/Favourite.php | 6 +-- plugins/Favourite/Entity/Favourite.php | 22 ++++---- plugins/Favourite/Favourite.php | 2 +- plugins/FileQuota/FileQuota.php | 4 +- plugins/Poll/Controller/AnswerPoll.php | 2 +- plugins/Poll/Controller/NewPoll.php | 4 +- plugins/Poll/Entity/Poll.php | 26 +++++----- plugins/Poll/Entity/PollResponse.php | 34 ++++++------ plugins/Poll/Poll.php | 2 +- .../ProfileColor/Controller/ProfileColor.php | 4 +- plugins/ProfileColor/Entity/ProfileColor.php | 20 +++---- plugins/ProfileColor/ProfileColor.php | 2 +- plugins/Repeat/Repeat.php | 14 ++--- src/Controller/{GSActor.php => Actor.php} | 28 +++++----- src/Controller/Network.php | 8 +-- src/Controller/Security.php | 49 ++++++++--------- src/Controller/Subscribers.php | 26 +++++----- src/Controller/Subscriptions.php | 26 +++++----- src/Controller/UserPanel.php | 8 +-- src/DataFixtures/CoreFixtures.php | 14 ++--- src/Entity/Activity.php | 12 ++--- src/Entity/{GSActor.php => Actor.php} | 32 ++++++------ .../{GSActorBlock.php => ActorBlock.php} | 10 ++-- .../{GSActorCircle.php => ActorCircle.php} | 18 +++---- src/Entity/{GSActorTag.php => ActorTag.php} | 16 +++--- ...SActorTagFollow.php => ActorTagFollow.php} | 38 +++++++------- ...ToAttachment.php => ActorToAttachment.php} | 20 +++---- src/Entity/Follow.php | 4 +- src/Entity/FollowQueue.php | 4 +- src/Entity/Group.php | 28 +++++----- src/Entity/GroupBlock.php | 20 +++---- src/Entity/GroupJoinQueue.php | 20 +++---- src/Entity/GroupMember.php | 32 ++++++------ src/Entity/Link.php | 2 +- src/Entity/LocalGroup.php | 2 +- src/Entity/LocalUser.php | 6 +-- src/Entity/Note.php | 52 ++++++++++--------- src/Entity/Notification.php | 20 +++---- src/Entity/UserNotificationPrefs.php | 14 ++--- src/Routes/{GSActor.php => Actor.php} | 6 +-- src/Routes/Subscribers.php | 2 +- src/Routes/Subscriptions.php | 2 +- src/Util/Common.php | 4 +- src/Util/Exception/EmailTakenException.php | 6 +-- src/Util/Exception/NicknameTakenException.php | 6 +-- src/Util/Form/ActorArrayTransformer.php | 8 +-- src/Util/Formatting.php | 20 +++---- src/Util/Notification/Notification.php | 10 ++-- templates/actor/view.html.twig | 6 +-- tests/Core/DB/DBTest.php | 32 ++++++------ tests/Core/DB/UpdateListenerTest.php | 2 +- tests/Core/FormTest.php | 6 +-- .../Entity/{GSActorTest.php => ActorTest.php} | 14 ++--- tests/Entity/AttachmentTest.php | 4 +- tests/Entity/GroupTest.php | 2 +- tests/Entity/NoteTest.php | 16 +++--- tests/Util/CommonTest.php | 8 +-- tests/Util/Form/ActorArrayTransformerTest.php | 8 +-- tests/Util/Notification/NotificationTest.php | 4 +- 73 files changed, 489 insertions(+), 484 deletions(-) rename src/Controller/{GSActor.php => Actor.php} (61%) rename src/Entity/{GSActor.php => Actor.php} (89%) rename src/Entity/{GSActorBlock.php => ActorBlock.php} (85%) rename src/Entity/{GSActorCircle.php => ActorCircle.php} (81%) rename src/Entity/{GSActorTag.php => ActorTag.php} (83%) rename src/Entity/{GSActorTagFollow.php => ActorTagFollow.php} (65%) rename src/Entity/{GSActorToAttachment.php => ActorToAttachment.php} (79%) rename src/Routes/{GSActor.php => Actor.php} (87%) rename tests/Entity/{GSActorTest.php => ActorTest.php} (79%) diff --git a/bin/generate_entity_diagrams b/bin/generate_entity_diagrams index e78e04f9c4..97a9c0018a 100755 --- a/bin/generate_entity_diagrams +++ b/bin/generate_entity_diagrams @@ -51,7 +51,7 @@ foreach ($files as $file) { foreach ($schema['fields'] as $field => $opts) { if (isset($opts['foreign key'])) { [$foreign_entity, $foreign_key] = explode('.', $opts['target']); - $foreign_table = Formatting::camelCaseToSnakeCase(preg_replace('/GSActor/', 'gsactor', $foreign_entity)); + $foreign_table = Formatting::camelCaseToSnakeCase(preg_replace('/Actor/', 'actor', $foreign_entity)); $edges[] = "{$table}:{$field} -- {$foreign_table}:{$foreign_key}"; } } diff --git a/bin/generate_entity_fields b/bin/generate_entity_fields index 70b98defbc..1ef140a834 100755 --- a/bin/generate_entity_fields +++ b/bin/generate_entity_fields @@ -50,7 +50,7 @@ foreach ($files as $file) { $nullable = !@$schema['fields'][$field]['not null'] ? '?' : ''; $type = types[$schema['fields'][$field]['type']]; $type = $type !== '' ? $nullable . $type : $type; - $method_name = str_replace([' ', 'Gsactor'], ['', 'GSActor'], ucwords(str_replace('_', ' ', $field))); + $method_name = str_replace([' ', 'actor'], ['', 'Actor'], ucwords(str_replace('_', ' ', $field))); $default = @$schema['fields'][$field]['default']; if (isset($default) && $nullable != '?' && $type != '\DateTimeInterface') { diff --git a/components/Avatar/Avatar.php b/components/Avatar/Avatar.php index 70fa877dc4..d830b2047f 100644 --- a/components/Avatar/Avatar.php +++ b/components/Avatar/Avatar.php @@ -38,7 +38,7 @@ class Avatar extends Component public function onAddRoute($r): bool { - $r->connect('avatar', '/actor/{gsactor_id<\d+>}/avatar/{size?full}', [Controller\Avatar::class, 'avatar_view']); + $r->connect('avatar', '/actor/{actor_id<\d+>}/avatar/{size?full}', [Controller\Avatar::class, 'avatar_view']); $r->connect('settings_avatar', '/settings/avatar', [Controller\Avatar::class, 'settings_avatar']); return Event::next; } @@ -63,64 +63,64 @@ class Avatar extends Component return Event::next; } - public function onGetAvatarUrl(int $gsactor_id, ?string &$url): bool + public function onGetAvatarUrl(int $actor_id, ?string &$url): bool { - $url = self::getAvatarUrl($gsactor_id); + $url = self::getAvatarUrl($actor_id); return Event::next; } - public function onAvatarUpdate(int $gsactor_id): bool + public function onAvatarUpdate(int $actor_id): bool { - Cache::delete('avatar-' . $gsactor_id); - Cache::delete('avatar-url-' . $gsactor_id); - Cache::delete('avatar-file-info-' . $gsactor_id); + Cache::delete('avatar-' . $actor_id); + Cache::delete('avatar-url-' . $actor_id); + Cache::delete('avatar-file-info-' . $actor_id); return Event::next; } // UTILS ---------------------------------- /** - * Get the avatar associated with the given GSActor id + * Get the avatar associated with the given Actor id */ - public static function getAvatar(?int $gsactor_id = null): Entity\Avatar + public static function getAvatar(?int $actor_id = null): Entity\Avatar { - $gsactor_id = $gsactor_id ?: Common::userId(); + $actor_id = $actor_id ?: Common::userId(); return GSFile::error(NoAvatarException::class, - $gsactor_id, - Cache::get("avatar-{$gsactor_id}", - function () use ($gsactor_id) { + $actor_id, + Cache::get("avatar-{$actor_id}", + function () use ($actor_id) { return DB::dql('select a from Component\Avatar\Entity\Avatar a ' . - 'where a.gsactor_id = :gsactor_id', - ['gsactor_id' => $gsactor_id]); + 'where a.actor_id = :actor_id', + ['actor_id' => $actor_id]); })); } /** - * Get the cached avatar associated with the given GSActor id, or the current user if not given + * Get the cached avatar associated with the given Actor id, or the current user if not given */ - public static function getAvatarUrl(?int $gsactor_id = null, string $size = 'full'): string + public static function getAvatarUrl(?int $actor_id = null, string $size = 'full'): string { - $gsactor_id = $gsactor_id ?: Common::userId(); - return Cache::get("avatar-url-{$gsactor_id}", function () use ($gsactor_id) { - return Router::url('avatar', ['gsactor_id' => $gsactor_id, 'size' => 'full']); + $actor_id = $actor_id ?: Common::userId(); + return Cache::get("avatar-url-{$actor_id}", function () use ($actor_id) { + return Router::url('avatar', ['actor_id' => $actor_id, 'size' => 'full']); }); } /** - * Get the cached avatar file info associated with the given GSActor id + * Get the cached avatar file info associated with the given Actor id * * Returns the avatar file's hash, mimetype, title and path. * Ensures exactly one cached value exists */ - public static function getAvatarFileInfo(int $gsactor_id): array + public static function getAvatarFileInfo(int $actor_id): array { - $res = Cache::get("avatar-file-info-{$gsactor_id}", - function () use ($gsactor_id) { + $res = Cache::get("avatar-file-info-{$actor_id}", + function () use ($actor_id) { return DB::dql('select f.id, f.filename, a.filename title, f.mimetype ' . 'from App\Entity\Attachment f ' . 'join Component\Avatar\Entity\Avatar a with f.id = a.attachment_id ' . - 'where a.gsactor_id = :gsactor_id', - ['gsactor_id' => $gsactor_id]); + 'where a.actor_id = :actor_id', + ['actor_id' => $actor_id]); } ); if ($res === []) { // Avatar not found diff --git a/components/Avatar/Controller/Avatar.php b/components/Avatar/Controller/Avatar.php index 3dfbebe418..c0b3e56796 100644 --- a/components/Avatar/Controller/Avatar.php +++ b/components/Avatar/Controller/Avatar.php @@ -48,11 +48,11 @@ class Avatar extends Controller /** * @throws Exception */ - public function avatar_view(Request $request, int $gsactor_id, string $size): Response + public function avatar_view(Request $request, int $actor_id, string $size): Response { switch ($size) { case 'full': - $res = \Component\Avatar\Avatar::getAvatarFileInfo($gsactor_id); + $res = \Component\Avatar\Avatar::getAvatarFileInfo($actor_id); return M::sendFile($res['filepath'], $res['mimetype'], $res['title']); default: throw new Exception('Not implemented'); @@ -74,12 +74,12 @@ class Avatar extends Controller $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $data = $form->getData(); - $user = Common::user(); - $gsactor_id = $user->getId(); + $data = $form->getData(); + $user = Common::user(); + $actor_id = $user->getId(); if ($data['remove'] == true) { try { - $avatar = DB::findOneBy('avatar', ['gsactor_id' => $gsactor_id]); + $avatar = DB::findOneBy('avatar', ['actor_id' => $actor_id]); $avatar->delete(); Event::handle('AvatarUpdate', [$user->getId()]); } catch (NotFoundException) { @@ -109,12 +109,12 @@ class Avatar extends Controller throw new ClientException('Invalid form'); } // Delete current avatar if there's one - $avatar = DB::find('avatar', ['gsactor_id' => $gsactor_id]); + $avatar = DB::find('avatar', ['actor_id' => $actor_id]); $avatar?->delete(); DB::persist($attachment); // Can only get new id after inserting DB::flush(); - DB::persist(AvatarEntity::create(['gsactor_id' => $gsactor_id, 'attachment_id' => $attachment->getId()])); + DB::persist(AvatarEntity::create(['actor_id' => $actor_id, 'attachment_id' => $attachment->getId()])); DB::flush(); Event::handle('AvatarUpdate', [$user->getId()]); } diff --git a/components/Avatar/Entity/Avatar.php b/components/Avatar/Entity/Avatar.php index defa860058..6bbdd6af9d 100644 --- a/components/Avatar/Entity/Avatar.php +++ b/components/Avatar/Entity/Avatar.php @@ -46,21 +46,21 @@ class Avatar extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart - private int $gsactor_id; + private int $actor_id; private int $attachment_id; private ?string $filename; private DateTimeInterface $created; private DateTimeInterface $modified; - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setAttachmentId(int $attachment_id): self @@ -119,7 +119,7 @@ class Avatar extends Entity public function getUrl(): string { - return Router::url('avatar', ['gsactor_id' => $this->gsactor_id]); + return Router::url('avatar', ['actor_id' => $this->actor_id]); } public function getAttachment(): Attachment @@ -157,13 +157,13 @@ class Avatar extends Entity return [ 'name' => 'avatar', 'fields' => [ - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'], 'attachment_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Attachment.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to attachment table'], 'filename' => ['type' => 'varchar', 'length' => 191, 'description' => 'file name of resource when available'], 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'], ], - 'primary key' => ['gsactor_id'], + 'primary key' => ['actor_id'], 'indexes' => [ 'avatar_attachment_id_idx' => ['attachment_id'], ], diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index 19050c7d39..a6aadb08c6 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -27,8 +27,8 @@ use App\Core\Event; use App\Core\Form; use function App\Core\I18n\_m; use App\Core\Modules\Component; +use App\Entity\Actor; use App\Entity\Attachment; -use App\Entity\GSActor; use App\Entity\Note; use App\Util\Common; use App\Util\Exception\ClientException; @@ -60,7 +60,7 @@ class Posting extends Component $actor_id = $user->getId(); $to_tags = []; $tags = Cache::get("actor-circle-{$actor_id}", - fn () => DB::dql('select c.tag from App\Entity\GSActorCircle c where c.tagger = :tagger', ['tagger' => $actor_id])); + fn () => DB::dql('select c.tag from App\Entity\ActorCircle c where c.tagger = :tagger', ['tagger' => $actor_id])); foreach ($tags as $t) { $t = $t['tag']; $to_tags[$t] = $t; @@ -109,12 +109,12 @@ class Posting extends Component return Event::next; } - public static function storeLocalNote(GSActor $actor, string $content, string $content_type, array $attachments, ?Note $reply_to = null, ?Note $repeat_of = null) + public static function storeLocalNote(Actor $actor, string $content, string $content_type, array $attachments, ?Note $reply_to = null, ?Note $repeat_of = null) { $rendered = null; Event::handle('RenderNoteContent', [$content, $content_type, &$rendered, $actor, $reply_to]); $note = Note::create([ - 'gsactor_id' => $actor->getId(), + 'actor_id' => $actor->getId(), 'content' => $content, 'content_type' => $content_type, 'rendered' => $rendered, @@ -125,7 +125,7 @@ class Posting extends Component DB::flush(); } - public function onRenderNoteContent(string $content, string $content_type, ?string &$rendered, GSActor $author, ?Note $reply_to = null) + public function onRenderNoteContent(string $content, string $content_type, ?string &$rendered, Actor $author, ?Note $reply_to = null) { if ($content_type === 'text/plain') { $content = Formatting::renderPlainText($content); diff --git a/docs/developer/src/cache.md b/docs/developer/src/cache.md index cabe2b38d6..af7f08863d 100644 --- a/docs/developer/src/cache.md +++ b/docs/developer/src/cache.md @@ -22,7 +22,7 @@ Store ```php /** - * Get the cached avatar file info associated with the given GSActor id + * Get the cached avatar file info associated with the given Actor id * * Returns the avatar file's hash, mimetype, title and path. * Ensures exactly one cached value exists diff --git a/plugins/ActivityStreamsTwo/ActivityStreamsTwo.php b/plugins/ActivityStreamsTwo/ActivityStreamsTwo.php index a0b804fe9e..3e35c70d8a 100644 --- a/plugins/ActivityStreamsTwo/ActivityStreamsTwo.php +++ b/plugins/ActivityStreamsTwo/ActivityStreamsTwo.php @@ -42,19 +42,19 @@ class ActivityStreamsTwo extends Plugin switch ($route) { case 'actor_view_id': case 'actor_view_nickname': - $response = ActorResponse::handle($vars['gsactor']); + $response = ActorResponse::handle($vars['actor']); return Event::stop; case 'note_view': $response = NoteResponse::handle($vars['note']); return Event::stop; case 'actor_favourites': - $response = LikeResponse::handle($vars['gsactor']); + $response = LikeResponse::handle($vars['actor']); return Event::stop; case 'actor_subscriptions': - $response = FollowingResponse::handle($vars['gsactor']); + $response = FollowingResponse::handle($vars['actor']); return Event::stop; case 'actor_subscribers': - $response = FollowersResponse::handle($vars['gsactor']); + $response = FollowersResponse::handle($vars['actor']); return Event::stop; default: return Event::next; diff --git a/plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php b/plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php index ecc8a13b22..9f1fd34693 100644 --- a/plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php +++ b/plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php @@ -3,7 +3,7 @@ namespace Plugin\ActivityStreamsTwo\Util\Model\EntityToType; use App\Core\Router\Router; -use App\Entity\GSActor; +use App\Entity\Actor; use DateTimeInterface; use Exception; use Plugin\ActivityStreamsTwo\Util\Type; @@ -11,13 +11,14 @@ use Plugin\ActivityStreamsTwo\Util\Type; class GSActorToType { /** - * @param GSActor $gsactor + * @param Actor $gsactor * - * @throws Exception + *@throws Exception * * @return Type + * */ - public static function translate(GSActor $gsactor) + public static function translate(Actor $gsactor) { $uri = Router::url('actor_view_id', ['id' => $gsactor->getId()], Router::ABSOLUTE_URL); $attr = [ diff --git a/plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php b/plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php index 72ebc1545c..c60b8e7b7b 100644 --- a/plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php +++ b/plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php @@ -2,21 +2,22 @@ namespace Plugin\ActivityStreamsTwo\Util\Response; -use App\Entity\GSActor; +use App\Entity\Actor; use Exception; use Plugin\ActivityStreamsTwo\Util\Model\EntityToType\GSActorToType; abstract class ActorResponse { /** - * @param GSActor $gsactor - * @param int $status The response status code + * @param Actor $gsactor + * @param int $status The response status code * - * @throws Exception + *@throws Exception * * @return TypeResponse + * */ - public static function handle(GSActor $gsactor, int $status = 200): TypeResponse + public static function handle(Actor $gsactor, int $status = 200): TypeResponse { $gsactor->getLocalUser(); // This throws exception if not a local user, which is intended return new TypeResponse(data: GSActorToType::translate($gsactor), status: $status); diff --git a/plugins/Cover/Controller/Cover.php b/plugins/Cover/Controller/Cover.php index 9f57a99b61..422b1f3cc7 100644 --- a/plugins/Cover/Controller/Cover.php +++ b/plugins/Cover/Controller/Cover.php @@ -98,7 +98,7 @@ class Cover } $file = GSFile::sanitizeAndStoreFileAsAttachment($sfile); $old_file = null; - $cover = DB::find('cover', ['gsactor_id' => $actor_id]); + $cover = DB::find('cover', ['gctor_id' => $actor_id]); // Must get old id before inserting another one if ($cover != null) { $old_file = $cover->delete(); @@ -107,7 +107,7 @@ class Cover DB::persist($file); // Can only get new id after inserting DB::flush(); - $cover = CoverEntity::create(['gsactor_id' => $actor_id, 'file_id' => $file->getId()]); + $cover = CoverEntity::create(['actor_id' => $actor_id, 'file_id' => $file->getId()]); DB::persist($cover); DB::flush(); // Only delete files if the commit went through @@ -118,7 +118,7 @@ class Cover } $removeForm = null; - $cover = DB::find('cover', ['gsactor_id' => $actor_id]); + $cover = DB::find('cover', ['actor_id' => $actor_id]); if ($cover != null) { $form2 = Form::create([ ['remove', SubmitType::class, ['label' => _m('Remove')]], @@ -143,7 +143,7 @@ class Cover */ public function cover() { - // $cover = DB::find('cover', ['gsactor_id' => Common::user()->getId()]); + // $cover = DB::find('cover', ['actor_id' => Common::user()->getId()]); // if ($cover == null) { // return new Response('Cover not found',Response::HTTP_NOT_FOUND); // } diff --git a/plugins/Cover/Cover.php b/plugins/Cover/Cover.php index d380b343fe..e195794128 100644 --- a/plugins/Cover/Cover.php +++ b/plugins/Cover/Cover.php @@ -75,7 +75,7 @@ class Cover extends Plugin public function onStartTwigPopulateVars(array &$vars): bool { /*if (Common::user() != null) { - $cover = DB::find('cover', ['gsactor_id' => Common::user()->getId()]); + $cover = DB::find('cover', ['actor_id' => Common::user()->getId()]); if ($cover != null) { $vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']]; } else { diff --git a/plugins/Cover/Entity/Cover.php b/plugins/Cover/Entity/Cover.php index 3dae39b9a6..438e7d45fb 100644 --- a/plugins/Cover/Entity/Cover.php +++ b/plugins/Cover/Entity/Cover.php @@ -41,20 +41,20 @@ class Cover extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart - private int $gsactor_id; + private int $actor_id; private int $attachment_id; private \DateTimeInterface $created; private \DateTimeInterface $modified; - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setAttachmentId(int $attachment_id): self @@ -131,7 +131,7 @@ class Cover extends Entity if (!$cascading) { $attachments = $this->getAttachment()->kill(); } else { - DB::remove(DB::getReference('cover', ['gsactor_id' => $this->gsactor_id])); + DB::remove(DB::getReference('cover', ['actor_id' => $this->actor_id])); $attachment_path = $this->getAttachmentPath(); $attachments[] = $attachment_path; if ($flush) { @@ -147,12 +147,12 @@ class Cover extends Entity return [ 'name' => 'cover', 'fields' => [ - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'], 'attachment_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Attachment.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to attachment table'], 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'], ], - 'primary key' => ['gsactor_id'], + 'primary key' => ['actor_id'], 'indexes' => [ 'cover_attachment_id_idx' => ['attachment_id'], ], diff --git a/plugins/Directory/Controller/Directory.php b/plugins/Directory/Controller/Directory.php index 118b3c1386..e93184effe 100644 --- a/plugins/Directory/Controller/Directory.php +++ b/plugins/Directory/Controller/Directory.php @@ -35,7 +35,7 @@ class Directory */ public function actors(Request $request) { - return ['_template' => 'directory/actors.html.twig', 'actors' => DB::dql('select g from App\Entity\GSActor g order by g.nickname ASC')]; + return ['_template' => 'directory/actors.html.twig', 'actors' => DB::dql('select g from App\Entity\Actor g order by g.nickname ASC')]; } /** diff --git a/plugins/Favourite/Controller/Favourite.php b/plugins/Favourite/Controller/Favourite.php index f158b7dfb3..ef4107e54a 100644 --- a/plugins/Favourite/Controller/Favourite.php +++ b/plugins/Favourite/Controller/Favourite.php @@ -32,7 +32,7 @@ class Favourite $notes = DB::dql( 'select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' . 'where n.id = f.note_id ' . - 'and f.gsactor_id = :id ' . + 'and f.actor_id = :id ' . 'order by f.created DESC', ['id' => $id] ); @@ -64,8 +64,8 @@ class Favourite { $notes = DB::dql('select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' . 'where n.id = f.note_id ' . - 'and f.gsactor_id != :id ' . - 'and n.gsactor_id = :id ' . + 'and f.actor_id != :id ' . + 'and n.actor_id = :id ' . 'order by f.created DESC' , ['id' => $id] ); diff --git a/plugins/Favourite/Entity/Favourite.php b/plugins/Favourite/Entity/Favourite.php index bfcce1ab48..8579a20bb7 100644 --- a/plugins/Favourite/Entity/Favourite.php +++ b/plugins/Favourite/Entity/Favourite.php @@ -27,7 +27,7 @@ class Favourite extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $note_id; - private int $gsactor_id; + private int $actor_id; private \DateTimeInterface $created; private \DateTimeInterface $modified; @@ -42,15 +42,15 @@ class Favourite extends Entity return $this->note_id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setCreated(DateTimeInterface $created): self @@ -83,15 +83,15 @@ class Favourite extends Entity return [ 'name' => 'favourite', 'fields' => [ - 'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'App\Entity\Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'note that is the favorite of'], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'App\Entity\GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'actor who favourited this note'], // note: formerly referenced notice.id, but we can now record remote users' favorites - 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], + 'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'App\Entity\Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'note that is the favorite of'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'App\Entity\Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'actor who favourited this note'], // note: formerly referenced notice.id, but we can now record remote users' favorites + 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], ], - 'primary key' => ['note_id', 'gsactor_id'], + 'primary key' => ['note_id', 'actor_id'], 'indexes' => [ 'fave_note_id_idx' => ['note_id'], - 'fave_actor_id_idx' => ['gsactor_id', 'modified'], + 'fave_actor_id_idx' => ['actor_id', 'modified'], 'fave_modified_idx' => ['modified'], ], ]; diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 0486d9d872..570ab46b60 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -61,7 +61,7 @@ class Favourite extends NoteHandlerPlugin } // if note is favoured, "is_set" is 1 - $opts = ['note_id' => $note->getId(), 'gsactor_id' => $user->getId()]; + $opts = ['note_id' => $note->getId(), 'actor_id' => $user->getId()]; $is_set = DB::find('favourite', $opts) !== null; $form_fav = Form::create([ ['submit_favourite', SubmitType::class, diff --git a/plugins/FileQuota/FileQuota.php b/plugins/FileQuota/FileQuota.php index a7b4334814..32d5b58b45 100644 --- a/plugins/FileQuota/FileQuota.php +++ b/plugins/FileQuota/FileQuota.php @@ -65,8 +65,8 @@ class FileQuota extends Plugin $query = <<getId(), $user->getId())) { throw new ServerException('User already responded to poll'); } - $pollResponse = PollResponse::create(['poll_id' => $poll->getId(), 'gsactor_id' => $user->getId(), 'selection' => $selection]); + $pollResponse = PollResponse::create(['poll_id' => $poll->getId(), 'actor_id' => $user->getId(), 'selection' => $selection]); DB::persist($pollResponse); DB::flush(); diff --git a/plugins/Poll/Controller/NewPoll.php b/plugins/Poll/Controller/NewPoll.php index dc6e9cfd81..15b66185fd 100644 --- a/plugins/Poll/Controller/NewPoll.php +++ b/plugins/Poll/Controller/NewPoll.php @@ -83,7 +83,7 @@ class NewPoll if ($form->isValid()) { $data = $form->getData(); - $note = Note::create(['gsactor_id' => $user->getId(), $is_local = true]); + $note = Note::create(['actor_id' => $user->getId(), $is_local = true]); DB::persist($note); Security::sanitize($question = $data['Question']); @@ -92,7 +92,7 @@ class NewPoll } $options = implode("\n",$opt); - $poll = Poll::create(['gsactor_id' => $user->getId(), 'question' => $question, 'options' => $options, 'note_id' => $note->getId()]); + $poll = Poll::create(['actor_id' => $user->getId(), 'question' => $question, 'options' => $options, 'note_id' => $note->getId()]); DB::persist($poll); DB::flush(); throw new RedirectException('root'); diff --git a/plugins/Poll/Entity/Poll.php b/plugins/Poll/Entity/Poll.php index 98291d77ca..7a4eecc974 100644 --- a/plugins/Poll/Entity/Poll.php +++ b/plugins/Poll/Entity/Poll.php @@ -41,7 +41,7 @@ class Poll extends Entity // @codeCoverageIgnoreStart private int $id; private ?string $uri; - private ?int $gsactor_id; + private ?int $actor_id; private int $note_id; private ?string $question; private ?string $options; @@ -70,15 +70,15 @@ class Poll extends Entity return $this->uri; } - public function setGSActorId(?int $gsactor_id): self + public function setActorId(?int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): ?int + public function getActorId(): ?int { - return $this->gsactor_id; + return $this->actor_id; } public function setNoteId(int $note_id): self @@ -150,14 +150,14 @@ class Poll extends Entity 'name' => 'poll', 'description' => 'Per-notice poll data for Poll plugin', 'fields' => [ - 'id' => ['type' => 'serial', 'not null' => true], - 'uri' => ['type' => 'varchar', 'length' => 191], - 'gsactor_id' => ['type' => 'int'], - 'note_id' => ['type' => 'int', 'not null' => true], - 'question' => ['type' => 'text'], - 'options' => ['type' => 'text'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'id' => ['type' => 'serial', 'not null' => true], + 'uri' => ['type' => 'varchar', 'length' => 191], + 'actor_id' => ['type' => 'int'], + 'note_id' => ['type' => 'int', 'not null' => true], + 'question' => ['type' => 'text'], + 'options' => ['type' => 'text'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ diff --git a/plugins/Poll/Entity/PollResponse.php b/plugins/Poll/Entity/PollResponse.php index e07f3260f8..dfce833741 100644 --- a/plugins/Poll/Entity/PollResponse.php +++ b/plugins/Poll/Entity/PollResponse.php @@ -42,7 +42,7 @@ class PollResponse extends Entity private int $id; private ?string $uri; private int $poll_id; - private ?int $gsactor_id; + private ?int $actor_id; private ?int $selection; private \DateTimeInterface $created; private \DateTimeInterface $modified; @@ -80,15 +80,15 @@ class PollResponse extends Entity return $this->poll_id; } - public function setGSActorId(?int $gsactor_id): self + public function setActorId(?int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): ?int + public function getActorId(): ?int { - return $this->gsactor_id; + return $this->actor_id; } public function setSelection(?int $selection): self @@ -140,25 +140,25 @@ class PollResponse extends Entity 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true], //'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'UUID to the response notice'), - 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'UUID to the response notice'], - 'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'], - 'gsactor_id' => ['type' => 'int'], - 'selection' => ['type' => 'int'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'UUID to the response notice'], + 'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'], + 'actor_id' => ['type' => 'int'], + 'selection' => ['type' => 'int'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['id'], 'unique keys' => [ //'poll_uri_key' => array('uri'), - //'poll_response_poll_id_gsactor_id_key' => ['poll_id', 'gsactor_id'], //doctrine bug? + //'poll_response_poll_id_actor_id_key' => ['poll_id', 'actor_id'], //doctrine bug? ], 'foreign keys' => [ 'foreign_poll' => ['poll', ['poll_id' => 'id']], ], 'indexes' => [ - 'poll_response_gsactor_id_poll_id_index' => ['gsactor_id', 'poll_id'], + 'poll_response_actor_id_poll_id_index' => ['actor_id', 'poll_id'], ], ]; } @@ -167,15 +167,15 @@ class PollResponse extends Entity * Checks if a user already responded to the poll * * @param int $pollId - * @param int $gsactorId user + * @param int $actorId user * * @return bool */ - public static function exits(int $pollId, int $gsactorId): bool + public static function exits(int $pollId, int $actorId): bool { $res = DB::dql('select pr from App\Entity\PollResponse pr - where pr.poll_id = :pollId and pr.gsactor_id = :gsactorId', - ['pollId' => $pollId, 'gsactorId' => $gsactorId]); + where pr.poll_id = :pollId and pr.actor_id = :actorId', + ['pollId' => $pollId, 'actorId' => $actorId]); return count($res) != 0; } } diff --git a/plugins/Poll/Poll.php b/plugins/Poll/Poll.php index 1a50aafe48..65154ae450 100644 --- a/plugins/Poll/Poll.php +++ b/plugins/Poll/Poll.php @@ -153,7 +153,7 @@ class Poll extends NoteHandlerPlugin if (Entity\PollResponse::exits($poll->getId(), $user->getId())) { throw new ServerException('User already responded to poll'); } - $pollResponse = Entity\PollResponse::create(['poll_id' => $poll->getId(), 'gsactor_id' => $user->getId(), 'selection' => $selection]); + $pollResponse = Entity\PollResponse::create(['poll_id' => $poll->getId(), 'actor_id' => $user->getId(), 'selection' => $selection]); DB::persist($pollResponse); DB::flush(); diff --git a/plugins/ProfileColor/Controller/ProfileColor.php b/plugins/ProfileColor/Controller/ProfileColor.php index ce5933f8d6..c7ef4b10bc 100644 --- a/plugins/ProfileColor/Controller/ProfileColor.php +++ b/plugins/ProfileColor/Controller/ProfileColor.php @@ -57,7 +57,7 @@ class ProfileColor { $user = Common::user(); $actor_id = $user->getId(); - $pcolor = DB::find('profile_color', ['gsactor_id' => $actor_id]); + $pcolor = DB::find('profile_color', ['actor_id' => $actor_id]); $color = '#000000'; if ($pcolor != null) { $color = $pcolor->getColor(); @@ -78,7 +78,7 @@ class ProfileColor DB::flush(); } - $pcolor = Entity\ProfileColor::create(['gsactor_id' => $actor_id, 'color' => $data['color']]); + $pcolor = Entity\ProfileColor::create(['actor_id' => $actor_id, 'color' => $data['color']]); DB::persist($pcolor); DB::flush(); throw new RedirectException(); diff --git a/plugins/ProfileColor/Entity/ProfileColor.php b/plugins/ProfileColor/Entity/ProfileColor.php index 81c31a42d4..9a7acf6d46 100644 --- a/plugins/ProfileColor/Entity/ProfileColor.php +++ b/plugins/ProfileColor/Entity/ProfileColor.php @@ -38,20 +38,20 @@ class ProfileColor extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart - private int $gsactor_id; + private int $actor_id; private string $color; private \DateTimeInterface $created; private \DateTimeInterface $modified; - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setColor(string $color): self @@ -94,12 +94,12 @@ class ProfileColor extends Entity return [ 'name' => 'profile_color', 'fields' => [ - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], - 'color' => ['type' => 'text', 'not null' => true, 'description' => 'color hex code'], - 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'], + 'color' => ['type' => 'text', 'not null' => true, 'description' => 'color hex code'], + 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created', 'default' => 'CURRENT_TIMESTAMP'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'], ], - 'primary key' => ['gsactor_id'], + 'primary key' => ['actor_id'], ]; } } diff --git a/plugins/ProfileColor/ProfileColor.php b/plugins/ProfileColor/ProfileColor.php index 8a3069e5b2..3095885168 100644 --- a/plugins/ProfileColor/ProfileColor.php +++ b/plugins/ProfileColor/ProfileColor.php @@ -80,7 +80,7 @@ class ProfileColor extends Plugin 'path' => 'profilecolor/profilecolor.html.twig', ];*/ if (Common::user() != null) { - $color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]); + $color = DB::find('profile_color', ['actor_id' => Common::user()->getId()]); if ($color != null) { $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]]; } diff --git a/plugins/Repeat/Repeat.php b/plugins/Repeat/Repeat.php index 48ebc922b0..76e6a26ddd 100644 --- a/plugins/Repeat/Repeat.php +++ b/plugins/Repeat/Repeat.php @@ -22,6 +22,7 @@ namespace Plugin\Repeat; use App\Core\DB\DB; use App\Core\Event; use App\Core\Form; +use function App\Core\I18n\_m; use App\Core\Modules\NoteHandlerPlugin; use App\Entity\Note; use App\Util\Common; @@ -29,7 +30,6 @@ use App\Util\Exception\RedirectException; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; -use function App\Core\I18n\_m; class Repeat extends NoteHandlerPlugin { @@ -45,7 +45,7 @@ class Repeat extends NoteHandlerPlugin return Event::next; } - $opts = ['gsactor_id' => $user->getId(), 'repeat_of' => $note->getId()]; + $opts = ['actor_id' => $user->getId(), 'repeat_of' => $note->getId()]; $is_set = DB::count('note', $opts) == 1; $form_repeat = Form::create([ ['submit_repeat', SubmitType::class, @@ -66,13 +66,13 @@ class Repeat extends NoteHandlerPlugin $request, $form_repeat, $note, "repeat-{$note->getId()}", function ($note, $data, $user) { if ($data["repeat-{$note->getId()}"] === '0') { DB::persist(Note::create([ - 'gsactor_id' => $user->getId(), - 'repeat_of' => $note->getId(), - 'content' => $note->getContent(), - 'is_local' => true, + 'actor_id' => $user->getId(), + 'repeat_of' => $note->getId(), + 'content' => $note->getContent(), + 'is_local' => true, ])); } else { - DB::remove(DB::findOneBy('note', ['gsactor_id' => $user->getId(), 'repeat_of' => $note->getId()])); + DB::remove(DB::findOneBy('note', ['actor_id' => $user->getId(), 'repeat_of' => $note->getId()])); } DB::flush(); diff --git a/src/Controller/GSActor.php b/src/Controller/Actor.php similarity index 61% rename from src/Controller/GSActor.php rename to src/Controller/Actor.php index d8713af3d8..5731ab6e6c 100644 --- a/src/Controller/GSActor.php +++ b/src/Controller/Actor.php @@ -27,43 +27,43 @@ use function App\Core\I18n\_m; use App\Util\Exception\ClientException; use Symfony\Component\HttpFoundation\Request; -class GSActor extends Controller +class Actor extends Controller { /** * Generic function that handles getting a representation for an actor from id */ - private function GSActorById(int $id, callable $handle) + private function ActorById(int $id, callable $handle) { - $gsactor = DB::findOneBy('gsactor', ['id' => $id]); - if (empty($gsactor)) { + $actor = DB::findOneBy('actor', ['id' => $id]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * Generic function that handles getting a representation for an actor from nickname */ - private function GSActorByNickname(string $nickname, callable $handle) + private function ActorByNickname(string $nickname, callable $handle) { - $user = DB::findOneBy('local_user', ['nickname' => $nickname]); - $gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); - if (empty($gsactor)) { + $user = DB::findOneBy('local_user', ['nickname' => $nickname]); + $actor = DB::findOneBy('actor', ['id' => $user->getId()]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * The page where the actor's info is shown */ - public function GSActorShowId(Request $request, int $id) + public function ActorShowId(Request $request, int $id) { - return $this->GSActorById($id, fn ($gsactor) => ['_template' => 'actor/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorById($id, fn ($actor) => ['_template' => 'actor/view.html.twig', 'actor' => $actor]); } - public function GSActorShowNickname(Request $request, string $nickname) + public function ActorShowNickname(Request $request, string $nickname) { - return $this->GSActorByNickname($nickname, fn ($gsactor) => ['_template' => 'actor/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorByNickname($nickname, fn ($actor) => ['_template' => 'actor/view.html.twig', 'actor' => $actor]); } } diff --git a/src/Controller/Network.php b/src/Controller/Network.php index 5fa320bea4..80ad2b2d11 100644 --- a/src/Controller/Network.php +++ b/src/Controller/Network.php @@ -68,7 +68,7 @@ class Network extends Controller public function home(Request $request, string $nickname) { try { - $target = DB::findOneBy('gsactor', ['nickname' => $nickname]); + $target = DB::findOneBy('actor', ['nickname' => $nickname]); } catch (NotFoundException) { throw new ClientException(_m('User {nickname} doesn\'t exist', ['{nickname}' => $nickname])); } @@ -78,7 +78,7 @@ class Network extends Controller select note.* from note left join -- left join ensures all returned notes' ids are not null ( -- Followed by target - select n.id from note n inner join follow f on n.gsactor_id = f.followed + select n.id from note n inner join follow f on n.actor_id = f.followed where f.follower = :target_actor_id union all -- Replies to notes by target @@ -89,7 +89,7 @@ class Network extends Controller union all -- Notes in groups target follows select gi.activity_id from group_inbox gi inner join group_member gm on gi.group_id = gm.group_id - where gm.gsactor_id = :target_actor_id + where gm.actor_id = :target_actor_id ) as s on s.id = note.id where @@ -125,7 +125,7 @@ END; { $actor_id = Common::ensureLoggedIn()->getId(); $notes = DB::dql('select n from App\Entity\Note n ' . - 'where n.reply_to is not null and n.gsactor_id = :id ' . + 'where n.reply_to is not null and n.actor_id = :id ' . 'order by n.created DESC', ['id' => $actor_id]); $notes_out = null; diff --git a/src/Controller/Security.php b/src/Controller/Security.php index 092f062138..f39ff08ffe 100644 --- a/src/Controller/Security.php +++ b/src/Controller/Security.php @@ -5,25 +5,24 @@ namespace App\Controller; use App\Core\Controller; use App\Core\DB\DB; use App\Core\Form; -use App\Util\Exception\DuplicateFoundException; -use App\Util\Exception\NicknameEmptyException; -use App\Util\Exception\NicknameReservedException; -use App\Util\Exception\NicknameTooLongException; -use App\Util\Exception\NicknameTooShortException; -use App\Util\Exception\NotImplementedException; -use Symfony\Component\HttpFoundation\Response; use function App\Core\I18n\_m; use App\Core\Log; use App\Core\VisibilityScope; +use App\Entity\Actor; use App\Entity\Follow; -use App\Entity\GSActor; use App\Entity\LocalUser; use App\Entity\Note; use App\Security\Authenticator; use App\Security\EmailVerifier; use App\Util\Common; +use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\EmailTakenException; +use App\Util\Exception\NicknameEmptyException; +use App\Util\Exception\NicknameReservedException; use App\Util\Exception\NicknameTakenException; +use App\Util\Exception\NicknameTooLongException; +use App\Util\Exception\NicknameTooShortException; +use App\Util\Exception\NotImplementedException; use App\Util\Exception\ServerException; use App\Util\Form\FormFields; use App\Util\Nickname; @@ -32,6 +31,7 @@ use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Validator\Constraints\Length; @@ -69,16 +69,15 @@ class Security extends Controller throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } - /** * * Register a user, making sure the nickname is not reserved and * possibly sending a confirmation email * - * @param Request $request + * @param Request $request * @param GuardAuthenticatorHandler $guard_handler - * @param Authenticator $authenticator - * @return array|Response|null + * @param Authenticator $authenticator + * * @throws EmailTakenException * @throws NicknameTakenException * @throws ServerException @@ -88,10 +87,12 @@ class Security extends Controller * @throws NicknameTooLongException * @throws NicknameTooShortException * @throws NotImplementedException + * + * @return null|array|Response */ - public function register(Request $request, + public function register(Request $request, GuardAuthenticatorHandler $guard_handler, - Authenticator $authenticator) + Authenticator $authenticator) { $form = Form::create([ ['nickname', TextType::class, [ @@ -105,16 +106,16 @@ class Security extends Controller 'max' => Nickname::MAX_LEN, 'maxMessage' => _m(['Your nickname must be at most # characters long'], ['count' => Nickname::MAX_LEN]), ]), ], - 'block_name' => 'nickname', - 'label_attr' => ['class' => 'section-form-label'], + 'block_name' => 'nickname', + 'label_attr' => ['class' => 'section-form-label'], 'invalid_message' => _m('Nickname not valid. Please provide a valid nickname.'), ]], ['email', EmailType::class, [ - 'label' => _m('Email'), - 'help' => _m('Desired email for this account (e.g., john@provider.com)'), - 'constraints' => [ new NotBlank(['message' => _m('Please enter an email') ])], - 'block_name' => 'email', - 'label_attr' => ['class' => 'section-form-label'], + 'label' => _m('Email'), + 'help' => _m('Desired email for this account (e.g., john@provider.com)'), + 'constraints' => [ new NotBlank(['message' => _m('Please enter an email') ])], + 'block_name' => 'email', + 'label_attr' => ['class' => 'section-form-label'], 'invalid_message' => _m('Email not valid. Please provide a valid email.'), ]], FormFields::repeated_password(), @@ -134,11 +135,11 @@ class Security extends Controller // If we do find something, there's a duplicate if ($user->getNickname() === $data['nickname']) { // Register page feedback on nickname already in use - $this->addFlash("verify_nickname_error", _m('Nickname is already in use on this server.')); + $this->addFlash('verify_nickname_error', _m('Nickname is already in use on this server.')); throw new NicknameTakenException; } else { // Register page feedback on email already in use - $this->addFlash("verify_email_error", _m('Email is already taken.')); + $this->addFlash('verify_email_error', _m('Email is already taken.')); throw new EmailTakenException; } } @@ -147,7 +148,7 @@ class Security extends Controller try { // This already checks if the nickname is being used - $actor = GSActor::create(['nickname' => $valid_nickname]); + $actor = Actor::create(['nickname' => $valid_nickname]); $user = LocalUser::create([ 'nickname' => $valid_nickname, 'outgoing_email' => $data['email'], diff --git a/src/Controller/Subscribers.php b/src/Controller/Subscribers.php index 46c50ac911..7512287bfd 100644 --- a/src/Controller/Subscribers.php +++ b/src/Controller/Subscribers.php @@ -32,38 +32,38 @@ class Subscribers extends Controller /** * Generic function that handles getting a representation for an actor from id */ - private function GSActorById(int $id, callable $handle) + private function ActorById(int $id, callable $handle) { - $gsactor = DB::findOneBy('gsactor', ['id' => $id]); - if (empty($gsactor)) { + $actor = DB::findOneBy('actor', ['id' => $id]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * Generic function that handles getting a representation for an actor from nickname */ - private function GSActorByNickname(string $nickname, callable $handle) + private function ActorByNickname(string $nickname, callable $handle) { - $user = DB::findOneBy('local_user', ['nickname' => $nickname]); - $gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); - if (empty($gsactor)) { + $user = DB::findOneBy('local_user', ['nickname' => $nickname]); + $actor = DB::findOneBy('actor', ['id' => $user->getId()]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * Collection of an actor's subscribers */ - public function GSActorShowId(Request $request, int $id) + public function ActorShowId(Request $request, int $id) { - return $this->GSActorById($id, fn ($gsactor) => ['_template' => 'subscribers/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorById($id, fn ($actor) => ['_template' => 'subscribers/view.html.twig', 'actor' => $actor]); } - public function GSActorShowNickname(Request $request, string $nickname) + public function ActorShowNickname(Request $request, string $nickname) { - return $this->GSActorByNickname($nickname, fn ($gsactor) => ['_template' => 'subscribers/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorByNickname($nickname, fn ($actor) => ['_template' => 'subscribers/view.html.twig', 'actor' => $actor]); } } diff --git a/src/Controller/Subscriptions.php b/src/Controller/Subscriptions.php index 02c101acfe..bf37d929dd 100644 --- a/src/Controller/Subscriptions.php +++ b/src/Controller/Subscriptions.php @@ -32,38 +32,38 @@ class Subscriptions extends Controller /** * Generic function that handles getting a representation for an actor from id */ - private function GSActorById(int $id, callable $handle) + private function ActorById(int $id, callable $handle) { - $gsactor = DB::findOneBy('gsactor', ['id' => $id]); - if (empty($gsactor)) { + $actor = DB::findOneBy('actor', ['id' => $id]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * Generic function that handles getting a representation for an actor from nickname */ - private function GSActorByNickname(string $nickname, callable $handle) + private function ActorByNickname(string $nickname, callable $handle) { - $user = DB::findOneBy('local_user', ['nickname' => $nickname]); - $gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); - if (empty($gsactor)) { + $user = DB::findOneBy('local_user', ['nickname' => $nickname]); + $actor = DB::findOneBy('actor', ['id' => $user->getId()]); + if (empty($actor)) { throw new ClientException(_m('No such actor.'), 404); } else { - return $handle($gsactor); + return $handle($actor); } } /** * Collection of an actor's subscriptions */ - public function GSActorShowId(Request $request, int $id) + public function ActorShowId(Request $request, int $id) { - return $this->GSActorById($id, fn ($gsactor) => ['_template' => 'subscriptions/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorById($id, fn ($actor) => ['_template' => 'subscriptions/view.html.twig', 'actor' => $actor]); } - public function GSActorShowNickname(Request $request, string $nickname) + public function ActorShowNickname(Request $request, string $nickname) { - return $this->GSActorByNickname($nickname, fn ($gsactor) => ['_template' => 'subscriptions/view.html.twig', 'gsactor' => $gsactor]); + return $this->ActorByNickname($nickname, fn ($actor) => ['_template' => 'subscriptions/view.html.twig', 'actor' => $actor]); } } diff --git a/src/Controller/UserPanel.php b/src/Controller/UserPanel.php index 8250169a13..3e4ef57f92 100644 --- a/src/Controller/UserPanel.php +++ b/src/Controller/UserPanel.php @@ -170,12 +170,12 @@ class UserPanel extends AbstractController $label = str_replace('_', ' ', ucfirst($name)); $labels = [ - 'target_gsactor_id' => 'Target Actors', - 'dm' => 'DM', + 'target_actor_id' => 'Target Actors', + 'dm' => 'DM', ]; $help = [ - 'target_gsactor_id' => 'If specified, these settings apply only to these profiles (comma- or space-separated list)', + 'target_actor_id' => 'If specified, these settings apply only to these profiles (comma- or space-separated list)', 'activity_by_followed' => 'Notify me when someone I follow has new activity', 'mention' => 'Notify me when mentions me in a notice', 'reply' => 'Notify me when someone replies to a notice made by me', @@ -192,7 +192,7 @@ class UserPanel extends AbstractController $form_defs['placeholder'][$name] = [$name, CheckboxType::class, ['data' => $val, 'label' => _m($labels[$name] ?? $label), 'help' => _m($help[$name])]]; break; case Types::INTEGER: - if ($name == 'target_gsactor_id') { + if ($name == 'target_actor_id') { $form_defs['placeholder'][$name] = [$name, TextType::class, ['data' => $val, 'label' => _m($labels[$name]), 'help' => _m($help[$name])], 'transformer' => ActorArrayTransformer::class]; } break; diff --git a/src/DataFixtures/CoreFixtures.php b/src/DataFixtures/CoreFixtures.php index 5cb23ec37f..1f3060956c 100644 --- a/src/DataFixtures/CoreFixtures.php +++ b/src/DataFixtures/CoreFixtures.php @@ -3,10 +3,10 @@ namespace App\DataFixtures; use App\Core\VisibilityScope; +use App\Entity\Actor; use App\Entity\Follow; use App\Entity\GroupInbox; use App\Entity\GroupMember; -use App\Entity\GSActor; use App\Entity\LocalGroup; use App\Entity\LocalUser; use App\Entity\Note; @@ -26,7 +26,7 @@ class CoreFixtures extends Fixture 'form_account_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('some password')]], 'taken_group' => [LocalGroup::class, 'setGroupId', []], ] as $nick => [$entity, $method, $extra_create]) { - $actor = GSActor::create(['nickname' => $nick]); + $actor = Actor::create(['nickname' => $nick]); $manager->persist($actor); $ent = $entity::create(array_merge(['nickname' => $nick], $extra_create)); // cannot use array spread for arrays with string keys $ent->{$method}($actor->getId()); @@ -37,16 +37,16 @@ class CoreFixtures extends Fixture $actors[$nick] = $actor; } - $n = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'some content']); + $n = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'some content']); $manager->persist($n); - $notes[] = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'some other content', 'reply_to' => $n->getId()]); - $notes[] = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER]); - $notes[] = $group_note = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP]); + $notes[] = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'some other content', 'reply_to' => $n->getId()]); + $notes[] = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER]); + $notes[] = $group_note = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP]); foreach ($notes as $note) { $manager->persist($note); } - $manager->persist(GroupMember::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'gsactor_id' => $actors['some_user']->getId()])); + $manager->persist(GroupMember::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'actor_id' => $actors['some_user']->getId()])); $manager->persist(GroupInbox::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'activity_id' => $group_note->getId()])); $manager->flush(); } diff --git a/src/Entity/Activity.php b/src/Entity/Activity.php index e0f7385403..de92c2a79d 100644 --- a/src/Entity/Activity.php +++ b/src/Entity/Activity.php @@ -40,7 +40,7 @@ class Activity extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $id; - private int $gsactor_id; + private int $actor_id; private string $verb; private string $object_type; private int $object_id; @@ -59,15 +59,15 @@ class Activity extends Entity return $this->id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setVerb(string $verb): self @@ -145,7 +145,7 @@ class Activity extends Entity 'name' => 'activity', 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true], - 'gsactor_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to gsactor table'], + 'actor_id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to actor table'], 'verb' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'internal activity verb, influenced by activity pub verbs'], 'object_type' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'the name of the table this object refers to'], 'object_id' => ['type' => 'int', 'not null' => true, 'description' => 'id in the referenced table'], diff --git a/src/Entity/GSActor.php b/src/Entity/Actor.php similarity index 89% rename from src/Entity/GSActor.php rename to src/Entity/Actor.php index 58698b8e4f..c908010bbd 100644 --- a/src/Entity/GSActor.php +++ b/src/Entity/Actor.php @@ -46,7 +46,7 @@ use Functional as F; * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActor extends Entity +class Actor extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart @@ -224,21 +224,21 @@ class GSActor extends Entity public static function getFromId(int $id): ?self { - return Cache::get('gsactor-id-' . $id, function () use ($id) { - return DB::find('gsactor', ['id' => $id]); + return Cache::get('actor-id-' . $id, function () use ($id) { + return DB::find('actor', ['id' => $id]); }); } public static function getFromNickname(string $nickname): ?self { - return Cache::get('gsactor-nick-' . $nickname, function () use ($nickname) { - return DB::findOneBy('gsactor', ['nickname' => $nickname]); + return Cache::get('actor-nick-' . $nickname, function () use ($nickname) { + return DB::findOneBy('actor', ['nickname' => $nickname]); }); } public static function getNicknameFromId(int $id): string { - return Cache::get('gsactor-nick-id-' . $id, function () use ($id) { + return Cache::get('actor-nick-id-' . $id, function () use ($id) { return self::getFromId($id)->getNickname(); }); } @@ -247,7 +247,7 @@ class GSActor extends Entity { return Cache::get('selftags-' . $this->id, function () { - return DB::findBy('gsactor_tag', ['tagger' => $this->id, 'tagged' => $this->id]); + return DB::findBy('actor_tag', ['tagger' => $this->id, 'tagged' => $this->id]); }, beta: $_test_force_recompute ? INF : 1.0); } @@ -258,7 +258,7 @@ class GSActor extends Entity $tag_to_remove = array_diff($tag_existing, $tags); $pt_to_remove = F\filter($existing, function ($pt) use ($tag_to_remove) { return in_array($pt->getTag(), $tag_to_remove); }); foreach ($tag_to_add as $tag) { - $pt = GSActorTag::create(['tagger' => $this->id, 'tagged' => $this->id, 'tag' => $tag]); + $pt = ActorTag::create(['tagger' => $this->id, 'tagged' => $this->id, 'tag' => $tag]); DB::persist($pt); } foreach ($pt_to_remove as $pt) { @@ -305,9 +305,9 @@ class GSActor extends Entity // Will throw exception on invalid input. $nickname = Nickname::normalize($nickname, check_already_used: false); return Cache::get('relative-nickname-' . $nickname . '-' . $this->getId(), - fn () => DB::dql('select a from gsactor a where ' . - 'a.id in (select followed from follow f join gsactor a on f.followed = a.id where and f.follower = :actor_id and a.nickname = :nickname) or' . - 'a.id in (select follower from follow f join gsactor a on f.follower = a.id where and f.followed = :actor_id and a.nickname = :nickname) or' . + fn () => DB::dql('select a from actor a where ' . + 'a.id in (select followed from follow f join actor a on f.followed = a.id where and f.follower = :actor_id and a.nickname = :nickname) or' . + 'a.id in (select follower from follow f join actor a on f.follower = a.id where and f.followed = :actor_id and a.nickname = :nickname) or' . 'a.nickname = :nickname' . 'limit 1', ['nickname' => $nickname, 'actor_id' => $this->getId()] @@ -327,13 +327,13 @@ class GSActor extends Entity public static function schemaDef(): array { $def = [ - 'name' => 'gsactor', - 'description' => 'local and remote users, groups and bots are gsactors, for instance', + 'name' => 'actor', + 'description' => 'local and remote users, groups and bots are actors, for instance', 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], 'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'], 'fullname' => ['type' => 'text', 'description' => 'display name'], - 'roles' => ['type' => 'int', 'not null' => true, 'default' => UserRoles::USER, 'description' => 'Bitmap of permissions this gsactor has'], + 'roles' => ['type' => 'int', 'not null' => true, 'default' => UserRoles::USER, 'description' => 'Bitmap of permissions this actor has'], 'homepage' => ['type' => 'text', 'description' => 'identifying URL'], 'bio' => ['type' => 'text', 'description' => 'descriptive biography'], 'location' => ['type' => 'text', 'description' => 'physical location'], @@ -346,10 +346,10 @@ class GSActor extends Entity ], 'primary key' => ['id'], 'indexes' => [ - 'gsactor_nickname_idx' => ['nickname'], + 'actor_nickname_idx' => ['nickname'], ], 'fulltext indexes' => [ - 'gsactor_fulltext_idx' => ['nickname', 'fullname', 'location', 'bio', 'homepage'], + 'actor_fulltext_idx' => ['nickname', 'fullname', 'location', 'bio', 'homepage'], ], ]; diff --git a/src/Entity/GSActorBlock.php b/src/Entity/ActorBlock.php similarity index 85% rename from src/Entity/GSActorBlock.php rename to src/Entity/ActorBlock.php index 35138b5482..49e77647e9 100644 --- a/src/Entity/GSActorBlock.php +++ b/src/Entity/ActorBlock.php @@ -23,7 +23,7 @@ use App\Core\Entity; use DateTimeInterface; /** - * Entity for User's GSActor Block + * Entity for User's Actor Block * * @category DB * @package GNUsocial @@ -36,7 +36,7 @@ use DateTimeInterface; * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActorBlock extends Entity +class ActorBlock extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart @@ -83,10 +83,10 @@ class GSActorBlock extends Entity public static function schemaDef(): array { return [ - 'name' => 'gsactor_block', + 'name' => 'actor_block', 'fields' => [ - 'blocker' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_block_blocker_fkey', 'not null' => true, 'description' => 'user making the block'], - 'blocked' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_block_blocked_fkey', 'not null' => true, 'description' => 'gsactor that is blocked'], + 'blocker' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_block_blocker_fkey', 'not null' => true, 'description' => 'user making the block'], + 'blocked' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_block_blocked_fkey', 'not null' => true, 'description' => 'actor that is blocked'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['blocker', 'blocked'], diff --git a/src/Entity/GSActorCircle.php b/src/Entity/ActorCircle.php similarity index 81% rename from src/Entity/GSActorCircle.php rename to src/Entity/ActorCircle.php index 3d4b8a4bb8..1e8f23c0b1 100644 --- a/src/Entity/GSActorCircle.php +++ b/src/Entity/ActorCircle.php @@ -23,7 +23,7 @@ use App\Core\Entity; use DateTimeInterface; /** - * Entity for List of gsactors + * Entity for List of actors * * @category DB * @package GNUsocial @@ -36,7 +36,7 @@ use DateTimeInterface; * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActorCircle extends Entity +class ActorCircle extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart @@ -119,11 +119,11 @@ class GSActorCircle extends Entity public static function schemaDef(): array { return [ - 'name' => 'gsactor_circle', - 'description' => 'a gsactor can have lists of gsactors, to separate their timeline', + 'name' => 'actor_circle', + 'description' => 'a actor can have lists of actors, to separate their timeline', 'fields' => [ - 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_list_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'], - 'tag' => ['type' => 'varchar', 'length' => 64, 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'gsactor tag'], // Join with GSActorTag // // so, Doctrine doesn't like that the target is not unique, even though the pair is + 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_list_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'], + 'tag' => ['type' => 'varchar', 'length' => 64, 'foreign key' => true, 'target' => 'ActorTag.tag', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'actor tag'], // Join with ActorTag // // so, Doctrine doesn't like that the target is not unique, even though the pair is 'description' => ['type' => 'text', 'description' => 'description of the people tag'], 'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], @@ -131,9 +131,9 @@ class GSActorCircle extends Entity ], 'primary key' => ['tagger', 'tag'], 'indexes' => [ - 'gsactor_list_modified_idx' => ['modified'], - 'gsactor_list_tag_idx' => ['tag'], - 'gsactor_list_tagger_tag_idx' => ['tagger', 'tag'], + 'actor_list_modified_idx' => ['modified'], + 'actor_list_tag_idx' => ['tag'], + 'actor_list_tagger_tag_idx' => ['tagger', 'tag'], ], ]; } diff --git a/src/Entity/GSActorTag.php b/src/Entity/ActorTag.php similarity index 83% rename from src/Entity/GSActorTag.php rename to src/Entity/ActorTag.php index 12ed8fc383..5aec526f8d 100644 --- a/src/Entity/GSActorTag.php +++ b/src/Entity/ActorTag.php @@ -23,7 +23,7 @@ use App\Core\Entity; use DateTimeInterface; /** - * Entity for GSActor Tag + * Entity for Actor Tag * * @category DB * @package GNUsocial @@ -36,7 +36,7 @@ use DateTimeInterface; * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActorTag extends Entity +class ActorTag extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart @@ -95,18 +95,18 @@ class GSActorTag extends Entity public static function schemaDef(): array { return [ - 'name' => 'gsactor_tag', + 'name' => 'actor_tag', 'fields' => [ - 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'nmae' => 'gsactor_tag_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'], - 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_tagged_fkey', 'not null' => true, 'description' => 'gsactor tagged'], + 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'user making the tag'], + 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'], 'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['tagger', 'tagged', 'tag'], 'indexes' => [ - 'gsactor_tag_modified_idx' => ['modified'], - 'gsactor_tag_tagger_tag_idx' => ['tagger', 'tag'], // For Circles - 'gsactor_tag_tagged_idx' => ['tagged'], + 'actor_tag_modified_idx' => ['modified'], + 'actor_tag_tagger_tag_idx' => ['tagger', 'tag'], // For Circles + 'actor_tag_tagged_idx' => ['tagged'], ], ]; } diff --git a/src/Entity/GSActorTagFollow.php b/src/Entity/ActorTagFollow.php similarity index 65% rename from src/Entity/GSActorTagFollow.php rename to src/Entity/ActorTagFollow.php index e0311d4a34..bf9a5859a6 100644 --- a/src/Entity/GSActorTagFollow.php +++ b/src/Entity/ActorTagFollow.php @@ -23,7 +23,7 @@ use App\Core\Entity; use DateTimeInterface; /** - * Entity for Gsactor Tag Subscription + * Entity for actor Tag Subscription * * @category DB * @package GNUsocial @@ -36,35 +36,35 @@ use DateTimeInterface; * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActorTagFollow extends Entity +class ActorTagFollow extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart - private int $gsactor_id; - private int $gsactor_tag; + private int $actor_id; + private int $actor_tag; private \DateTimeInterface $created; private \DateTimeInterface $modified; - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } - public function setGSActorTag(int $gsactor_tag): self + public function setActorTag(int $actor_tag): self { - $this->gsactor_tag = $gsactor_tag; + $this->actor_tag = $actor_tag; return $this; } - public function getGSActorTag(): int + public function getActorTag(): int { - return $this->gsactor_tag; + return $this->actor_tag; } public function setCreated(DateTimeInterface $created): self @@ -95,18 +95,18 @@ class GSActorTagFollow extends Entity public static function schemaDef(): array { return [ - 'name' => 'gsactor_tag_follow', + 'name' => 'actor_tag_follow', 'fields' => [ - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_follow_gsactor_id_fkey', 'not null' => true, 'description' => 'foreign key to gsactor table'], - 'gsactor_tag' => ['type' => 'int', // 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'one to one', // tag can't unique, but doctrine doesn't understand this - 'name' => 'gsactor_tag_follow_gsactor_tag_fkey', 'not null' => true, 'description' => 'foreign key to gsactor_tag', ], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_follow_actor_id_fkey', 'not null' => true, 'description' => 'foreign key to actor table'], + 'actor_tag' => ['type' => 'int', // 'foreign key' => true, 'target' => 'ActorTag.tag', 'multiplicity' => 'one to one', // tag can't unique, but doctrine doesn't understand this + 'name' => 'actor_tag_follow_actor_tag_fkey', 'not null' => true, 'description' => 'foreign key to actor_tag', ], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], - 'primary key' => ['gsactor_tag_id', 'gsactor_id'], + 'primary key' => ['actor_tag_id', 'actor_id'], 'indexes' => [ - 'gsactor_tag_follow_gsactor_id_idx' => ['gsactor_id'], - 'gsactor_tag_follow_created_idx' => ['created'], + 'actor_tag_follow_actor_id_idx' => ['actor_id'], + 'actor_tag_follow_created_idx' => ['created'], ], ]; } diff --git a/src/Entity/GSActorToAttachment.php b/src/Entity/ActorToAttachment.php similarity index 79% rename from src/Entity/GSActorToAttachment.php rename to src/Entity/ActorToAttachment.php index be09b6b723..9f116e31fe 100644 --- a/src/Entity/GSActorToAttachment.php +++ b/src/Entity/ActorToAttachment.php @@ -32,12 +32,12 @@ use DateTimeInterface; * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ -class GSActorToAttachment extends Entity +class ActorToAttachment extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart private int $attachment_id; - private int $gsactor_id; + private int $actor_id; private \DateTimeInterface $modified; public function setAttachmentId(int $attachment_id): self @@ -51,15 +51,15 @@ class GSActorToAttachment extends Entity return $this->attachment_id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setModified(DateTimeInterface $modified): self @@ -79,16 +79,16 @@ class GSActorToAttachment extends Entity public static function schemaDef(): array { return [ - 'name' => 'gsactor_to_attachment', + 'name' => 'actor_to_attachment', 'fields' => [ 'attachment_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Attachment.id', 'multiplicity' => 'one to one', 'name' => 'attachment_to_note_attachment_id_fkey', 'not null' => true, 'description' => 'id of attachment'], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'attachment_to_note_note_id_fkey', 'not null' => true, 'description' => 'id of the note it belongs to'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'attachment_to_note_note_id_fkey', 'not null' => true, 'description' => 'id of the note it belongs to'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], - 'primary key' => ['attachment_id', 'gsactor_id'], + 'primary key' => ['attachment_id', 'actor_id'], 'indexes' => [ 'attachment_id_idx' => ['attachment_id'], - 'gsactor_id_idx' => ['gsactor_id'], + 'actor_id_idx' => ['actor_id'], ], ]; } diff --git a/src/Entity/Follow.php b/src/Entity/Follow.php index dd4d50a230..bd75111e24 100644 --- a/src/Entity/Follow.php +++ b/src/Entity/Follow.php @@ -97,8 +97,8 @@ class Follow extends Entity return [ 'name' => 'follow', 'fields' => [ - 'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'follow_follower_fkey', 'not null' => true, 'description' => 'gsactor listening'], - 'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'follow_followed_fkey', 'not null' => true, 'description' => 'gsactor being listened to'], + 'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'follow_follower_fkey', 'not null' => true, 'description' => 'actor listening'], + 'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'follow_followed_fkey', 'not null' => true, 'description' => 'actor being listened to'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], diff --git a/src/Entity/FollowQueue.php b/src/Entity/FollowQueue.php index 248ab777fc..a661fd62f5 100644 --- a/src/Entity/FollowQueue.php +++ b/src/Entity/FollowQueue.php @@ -86,8 +86,8 @@ class FollowQueue extends Entity 'name' => 'follow_queue', 'description' => 'Holder for Follow requests awaiting moderation.', 'fields' => [ - 'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_follower_fkey', 'not null' => true, 'description' => 'gsactor making the request'], - 'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_followed_fkey', 'not null' => true, 'description' => 'gsactor being followed'], + 'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_follower_fkey', 'not null' => true, 'description' => 'actor making the request'], + 'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_followed_fkey', 'not null' => true, 'description' => 'actor being followed'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], ], 'primary key' => ['follower', 'followed'], diff --git a/src/Entity/Group.php b/src/Entity/Group.php index 283c59b2ce..945e27019c 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -47,7 +47,7 @@ class Group extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $id; - private int $gsactor_id; + private int $actor_id; private ?string $nickname; private ?string $fullname; private ?string $homepage; @@ -76,15 +76,15 @@ class Group extends Entity return $this->id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setNickname(?string $nickname): self @@ -266,12 +266,12 @@ class Group extends Entity // @codeCoverageIgnoreEnd // }}} Autocode - public function getActor(): GSActor + public function getActor(): Actor { - return GSActor::getFromId($this->getId()); + return Actor::getFromId($this->getId()); } - public static function getFromNickname(string $nickname, ?GSActor $actor = null): ?self + public static function getFromNickname(string $nickname, ?Actor $actor = null): ?self { $nickname = Nickname::normalize($nickname, check_already_used: false); $group = null; @@ -295,7 +295,7 @@ class Group extends Entity 'name' => '`group`', 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'foreign key to actor table'], 'nickname' => ['type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'], 'fullname' => ['type' => 'varchar', 'length' => 191, 'description' => 'display name'], 'homepage' => ['type' => 'varchar', 'length' => 191, 'description' => 'URL, cached so we dont regenerate'], @@ -303,7 +303,7 @@ class Group extends Entity 'is_local' => ['type' => 'bool', 'description' => 'whether this group was created in this instance'], 'location' => ['type' => 'varchar', 'length' => 191, 'description' => 'related physical location, if any'], 'original_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'original size logo'], - 'homepage_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'homepage (gsactor) size logo'], + 'homepage_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'homepage (actor) size logo'], 'stream_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'], 'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'], 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], @@ -315,12 +315,12 @@ class Group extends Entity ], 'primary key' => ['id'], 'unique keys' => [ - 'user_group_uri_key' => ['uri'], - 'user_gsactor_id_key' => ['gsactor_id'], + 'user_group_uri_key' => ['uri'], + 'user_actor_id_key' => ['actor_id'], ], 'indexes' => [ - 'user_group_nickname_idx' => ['nickname'], - 'user_group_gsactor_id_idx' => ['gsactor_id'], + 'user_group_nickname_idx' => ['nickname'], + 'user_group_actor_id_idx' => ['actor_id'], ], ]; } diff --git a/src/Entity/GroupBlock.php b/src/Entity/GroupBlock.php index bf0dfc16ea..a054420360 100644 --- a/src/Entity/GroupBlock.php +++ b/src/Entity/GroupBlock.php @@ -41,7 +41,7 @@ class GroupBlock extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $group_id; - private int $blocked_gsactor; + private int $blocked_actor; private int $blocker_user; private \DateTimeInterface $modified; @@ -56,15 +56,15 @@ class GroupBlock extends Entity return $this->group_id; } - public function setBlockedGSActor(int $blocked_gsactor): self + public function setBlockedActor(int $blocked_actor): self { - $this->blocked_gsactor = $blocked_gsactor; + $this->blocked_actor = $blocked_actor; return $this; } - public function getBlockedGSActor(): int + public function getBlockedActor(): int { - return $this->blocked_gsactor; + return $this->blocked_actor; } public function setBlockerUser(int $blocker_user): self @@ -97,12 +97,12 @@ class GroupBlock extends Entity return [ 'name' => 'group_block', 'fields' => [ - 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'group gsactor is blocked from'], - 'blocked_gsactor' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'gsactor that is blocked'], - 'blocker_user' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'user making the block'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'group actor is blocked from'], + 'blocked_actor' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'actor that is blocked'], + 'blocker_user' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'user making the block'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], - 'primary key' => ['group_id', 'blocked_gsactor'], + 'primary key' => ['group_id', 'blocked_actor'], ]; } } diff --git a/src/Entity/GroupJoinQueue.php b/src/Entity/GroupJoinQueue.php index 5f3ba77016..50f4748d7a 100644 --- a/src/Entity/GroupJoinQueue.php +++ b/src/Entity/GroupJoinQueue.php @@ -39,18 +39,18 @@ class GroupJoinQueue extends Entity { // {{{ Autocode // @codeCoverageIgnoreStart - private int $gsactor_id; + private int $actor_id; private int $group_id; - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setGroupId(int $group_id): self @@ -73,13 +73,13 @@ class GroupJoinQueue extends Entity 'name' => 'group_join_queue', 'description' => 'Holder for group join requests awaiting moderation.', 'fields' => [ - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'group_join_queue_gsactor_id_fkey', 'not null' => true, 'description' => 'remote or local gsactor making the request'], - 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'name' => 'group_join_queue_group_id_fkey', 'not null' => true, 'description' => 'remote or local group to join, if any'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'group_join_queue_actor_id_fkey', 'not null' => true, 'description' => 'remote or local actor making the request'], + 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'name' => 'group_join_queue_group_id_fkey', 'not null' => true, 'description' => 'remote or local group to join, if any'], ], - 'primary key' => ['gsactor_id', 'group_id'], + 'primary key' => ['actor_id', 'group_id'], 'indexes' => [ - 'group_join_queue_gsactor_id_idx' => ['gsactor_id'], - 'group_join_queue_group_id_idx' => ['group_id'], + 'group_join_queue_actor_id_idx' => ['actor_id'], + 'group_join_queue_group_id_idx' => ['group_id'], ], ]; } diff --git a/src/Entity/GroupMember.php b/src/Entity/GroupMember.php index 1f83deba6d..59da000354 100644 --- a/src/Entity/GroupMember.php +++ b/src/Entity/GroupMember.php @@ -41,7 +41,7 @@ class GroupMember extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $group_id; - private int $gsactor_id; + private int $actor_id; private ?bool $is_admin; private ?string $uri; private \DateTimeInterface $created; @@ -58,15 +58,15 @@ class GroupMember extends Entity return $this->group_id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setIsAdmin(?bool $is_admin): self @@ -121,22 +121,22 @@ class GroupMember extends Entity return [ 'name' => 'group_member', 'fields' => [ - 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'one to one', 'name' => 'group_member_group_id_fkey', 'not null' => true, 'description' => 'foreign key to group table'], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'group_member_gsactor_id_fkey', 'not null' => true, 'description' => 'foreign key to gsactor table'], - 'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this actor an admin?'], - 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], - 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'one to one', 'name' => 'group_member_group_id_fkey', 'not null' => true, 'description' => 'foreign key to group table'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'group_member_actor_id_fkey', 'not null' => true, 'description' => 'foreign key to actor table'], + 'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this actor an admin?'], + 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], + 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], - 'primary key' => ['group_id', 'gsactor_id'], + 'primary key' => ['group_id', 'actor_id'], 'unique keys' => [ 'group_member_uri_key' => ['uri'], ], 'indexes' => [ - 'group_member_gsactor_id_idx' => ['gsactor_id'], - 'group_member_created_idx' => ['created'], - 'group_member_gsactor_id_created_idx' => ['gsactor_id', 'created'], - 'group_member_group_id_created_idx' => ['group_id', 'created'], + 'group_member_actor_id_idx' => ['actor_id'], + 'group_member_created_idx' => ['created'], + 'group_member_actor_id_created_idx' => ['actor_id', 'created'], + 'group_member_group_id_created_idx' => ['group_id', 'created'], ], ]; } diff --git a/src/Entity/Link.php b/src/Entity/Link.php index c572209579..cf72e21d35 100644 --- a/src/Entity/Link.php +++ b/src/Entity/Link.php @@ -187,7 +187,7 @@ class Link extends Entity ], 'primary key' => ['id'], 'indexes' => [ - 'gsactor_url_hash_idx' => ['url_hash'], + 'actor_url_hash_idx' => ['url_hash'], ], ]; } diff --git a/src/Entity/LocalGroup.php b/src/Entity/LocalGroup.php index 9713ac867f..4ff8d4a545 100644 --- a/src/Entity/LocalGroup.php +++ b/src/Entity/LocalGroup.php @@ -96,7 +96,7 @@ class LocalGroup extends Entity public function getActor() { - return DB::find('gsactor', ['id' => $this->group_id]); + return DB::find('actor', ['id' => $this->group_id]); } public static function schemaDef(): array diff --git a/src/Entity/LocalUser.php b/src/Entity/LocalUser.php index 6e8f4f27eb..5326ebcb1f 100644 --- a/src/Entity/LocalUser.php +++ b/src/Entity/LocalUser.php @@ -259,7 +259,7 @@ class LocalUser extends Entity implements UserInterface public function getActor() { - return DB::find('gsactor', ['id' => $this->id]); + return DB::find('actor', ['id' => $this->id]); } /** @@ -390,8 +390,8 @@ class LocalUser extends Entity implements UserInterface 'name' => 'local_user', 'description' => 'local users, bots, etc', 'fields' => [ - 'id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], - 'nickname' => ['type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'nickname or username, foreign key to gsactor'], + 'id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to actor table'], + 'nickname' => ['type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'nickname or username, foreign key to actor'], 'password' => ['type' => 'varchar', 'length' => 191, 'description' => 'salted password, can be null for users with federated authentication'], 'outgoing_email' => ['type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery, notifications, etc.'], 'incoming_email' => ['type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'], diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 306a1db8e8..d0da8bbb6e 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -44,7 +44,7 @@ class Note extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $id; - private int $gsactor_id; + private int $actor_id; private string $content_type = 'text/plain'; private string $content; private string $rendered; @@ -68,15 +68,15 @@ class Note extends Entity return $this->id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } /** @@ -89,6 +89,8 @@ class Note extends Entity /** * @param string $content_type + * + * @return Note */ public function setContentType(string $content_type): self { @@ -209,20 +211,20 @@ class Note extends Entity // @codeCoverageIgnoreEnd // }}} Autocode - public function getActor(): GSActor + public function getActor(): Actor { - return GSActor::getFromId($this->gsactor_id); + return Actor::getFromId($this->actor_id); } public function getActorNickname(): string { - return GSActor::getNicknameFromId($this->gsactor_id); + return Actor::getNicknameFromId($this->actor_id); } public function getAvatarUrl() { $url = null; - Event::handle('GetAvatarUrl', [$this->getGSActorId(), &$url]); + Event::handle('GetAvatarUrl', [$this->getActorId(), &$url]); return $url; } @@ -272,7 +274,7 @@ class Note extends Entity if (!empty($this->reply_to)) { return Cache::get('note-reply-to-' . $this->id, function () { return DB::dql('select g from App\Entity\Note n join ' . - 'App\Entity\GSActor g with n.gsactor_id = g.id where n.reply_to = :reply', + 'App\Entity\Actor g with n.actor_id = g.id where n.reply_to = :reply', ['reply' => $this->reply_to])[0]->getNickname(); }); } @@ -282,18 +284,18 @@ class Note extends Entity /** * Whether this note is visible to the given actor */ - public function isVisibleTo(GSActor | LocalUser $a): bool + public function isVisibleTo(Actor | LocalUser $a): bool { $scope = VisibilityScope::create($this->scope); return $scope->public || ($scope->follower - && null != DB::find('follow', ['follower' => $a->getId(), 'followed' => $this->gsactor_id])) + && null != DB::find('follow', ['follower' => $a->getId(), 'followed' => $this->actor_id])) || ($scope->addressee - && null != DB::find('notification', ['activity_id' => $this->id, 'gsactor_id' => $a->getId()])) + && null != DB::find('notification', ['activity_id' => $this->id, 'actor_id' => $a->getId()])) || ($scope->group && [] != DB::dql('select m from group_member m ' . 'join group_inbox i with m.group_id = i.group_id ' . 'join note n with i.activity_id = n.id ' . - 'where n.id = :note_id and m.gsactor_id = :actor_id', + 'where n.id = :note_id and m.actor_id = :actor_id', ['note_id' => $this->id, 'actor_id' => $a->getId()])); } @@ -312,7 +314,7 @@ class Note extends Entity $processed_attachments = []; foreach ($attachments as $f) { - Event::handle('EnforceUserFileQuota', [$f->getSize(), $args['gsactor_id']]); + Event::handle('EnforceUserFileQuota', [$f->getSize(), $args['actor_id']]); $processed_attachments[] = [GSFile::sanitizeAndStoreFileAsAttachment($f), $f->getClientOriginalName()]; } @@ -321,8 +323,8 @@ class Note extends Entity if ($processed_attachments != []) { foreach ($processed_attachments as [$a, $fname]) { - if (DB::count('gsactor_to_attachment', $args = ['attachment_id' => $a->getId(), 'gsactor_id' => $args['gsactor_id']]) === 0) { - DB::persist(GSActorToAttachment::create($args)); + if (DB::count('actor_to_attachment', $args = ['attachment_id' => $a->getId(), 'actor_id' => $args['actor_id']]) === 0) { + DB::persist(ActorToAttachment::create($args)); } DB::persist(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId(), 'title' => $fname])); } @@ -332,7 +334,7 @@ class Note extends Entity } /** - * @return GSActor[] + * @return Actor[] */ public function getAttentionProfiles(): array { @@ -346,7 +348,7 @@ class Note extends Entity 'name' => 'note', 'fields' => [ 'id' => ['type' => 'serial', 'not null' => true], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'who made the note'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'who made the note'], 'content' => ['type' => 'text', 'not null' => true, 'description' => 'note content'], 'content_type' => ['type' => 'varchar', 'not null' => true, 'default' => 'text/plain', 'length' => 129, 'description' => 'A note can be written in a multitude of formats such as text/plain, text/markdown, application/x-latex, and text/html'], 'rendered' => ['type' => 'text', 'description' => 'rendered note content, so we can keep the microtags (if not local)'], @@ -361,12 +363,12 @@ class Note extends Entity ], 'primary key' => ['id'], 'indexes' => [ - 'note_created_id_is_local_idx' => ['created', 'is_local'], - 'note_gsactor_created_idx' => ['gsactor_id', 'created'], - 'note_is_local_created_gsactor_idx' => ['is_local', 'created', 'gsactor_id'], - 'note_repeat_of_created_idx' => ['repeat_of', 'created'], - 'note_conversation_created_idx' => ['conversation', 'created'], - 'note_reply_to_idx' => ['reply_to'], + 'note_created_id_is_local_idx' => ['created', 'is_local'], + 'note_actor_created_idx' => ['actor_id', 'created'], + 'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'], + 'note_repeat_of_created_idx' => ['repeat_of', 'created'], + 'note_conversation_created_idx' => ['conversation', 'created'], + 'note_reply_to_idx' => ['reply_to'], ], 'fulltext indexes' => ['notice_fulltext_idx' => ['content']], ]; diff --git a/src/Entity/Notification.php b/src/Entity/Notification.php index 761be9d050..4cd8a05bd1 100644 --- a/src/Entity/Notification.php +++ b/src/Entity/Notification.php @@ -41,7 +41,7 @@ class Notification extends Entity // {{{ Autocode // @codeCoverageIgnoreStart private int $activity_id; - private int $gsactor_id; + private int $actor_id; private ?string $reason; private \DateTimeInterface $created; private \DateTimeInterface $modified; @@ -57,15 +57,15 @@ class Notification extends Entity return $this->activity_id; } - public function setGSActorId(int $gsactor_id): self + public function setActorId(int $actor_id): self { - $this->gsactor_id = $gsactor_id; + $this->actor_id = $actor_id; return $this; } - public function getGSActorId(): int + public function getActorId(): int { - return $this->gsactor_id; + return $this->actor_id; } public function setReason(?string $reason): self @@ -108,18 +108,18 @@ class Notification extends Entity { return [ 'name' => 'notification', - 'description' => 'Activity notification for gsactors (that are not a mention and not result of a subscription)', + 'description' => 'Activity notification for actors (that are not a mention and not result of a subscription)', 'fields' => [ 'activity_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Activity.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'activity_id to give attention'], - 'gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'gsactor_id for feed receiver'], - 'reason' => ['type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of gsactor_id'], + 'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'actor_id for feed receiver'], + 'reason' => ['type' => 'varchar', 'length' => 191, 'description' => 'Optional reason why this was brought to the attention of actor_id'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], - 'primary key' => ['activity_id', 'gsactor_id'], + 'primary key' => ['activity_id', 'actor_id'], 'indexes' => [ 'attention_activity_id_idx' => ['activity_id'], - 'attention_gsactor_id_idx' => ['gsactor_id'], + 'attention_actor_id_idx' => ['actor_id'], ], ]; } diff --git a/src/Entity/UserNotificationPrefs.php b/src/Entity/UserNotificationPrefs.php index 739ef9f51c..d0c7d2171d 100644 --- a/src/Entity/UserNotificationPrefs.php +++ b/src/Entity/UserNotificationPrefs.php @@ -38,7 +38,7 @@ class UserNotificationPrefs extends Entity // @codeCoverageIgnoreStart private int $user_id; private string $transport; - private ?int $target_gsactor_id; + private ?int $target_actor_id; private bool $activity_by_followed = true; private bool $mention = true; private bool $reply = true; @@ -73,15 +73,15 @@ class UserNotificationPrefs extends Entity return $this->transport; } - public function setTargetGSActorId(?int $target_gsactor_id): self + public function setTargetActorId(?int $target_actor_id): self { - $this->target_gsactor_id = $target_gsactor_id; + $this->target_actor_id = $target_actor_id; return $this; } - public function getTargetGSActorId(): ?int + public function getTargetActorId(): ?int { - return $this->target_gsactor_id; + return $this->target_actor_id; } public function setActivityByFollowed(bool $activity_by_followed): self @@ -215,7 +215,7 @@ class UserNotificationPrefs extends Entity 'fields' => [ 'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true], 'transport' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex email. xmpp, aim)'], - 'target_gsactor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'default' => null, 'description' => 'If not null, settings are specific only to a given gsactors'], + 'target_actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'default' => null, 'description' => 'If not null, settings are specific only to a given actors'], 'activity_by_followed' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when a new activity by someone we follow is made'], 'mention' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when mentioned by someone we do not follow'], 'reply' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when someone replies to a notice made by us'], @@ -230,7 +230,7 @@ class UserNotificationPrefs extends Entity ], 'primary key' => ['user_id', 'transport'], 'indexes' => [ - 'user_notification_prefs_user_target_gsactor_idx' => ['user_id', 'target_gsactor_id'], + 'user_notification_prefs_user_target_actor_idx' => ['user_id', 'target_actor_id'], ], ]; } diff --git a/src/Routes/GSActor.php b/src/Routes/Actor.php similarity index 87% rename from src/Routes/GSActor.php rename to src/Routes/Actor.php index 58f1b7be41..53e36dc7e2 100644 --- a/src/Routes/GSActor.php +++ b/src/Routes/Actor.php @@ -37,13 +37,13 @@ use App\Controller as C; use App\Core\Router\RouteLoader; use App\Util\Nickname; -abstract class GSActor +abstract class Actor { const LOAD_ORDER = 30; public static function load(RouteLoader $r): void { - $r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\GSActor::class, 'GSActorShowId']); - $r->connect(id: 'actor_view_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\GSActor::class, 'GSActorShowNickname'], options: ['is_system_path' => false]); + $r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\Actor::class, 'ActorShowId']); + $r->connect(id: 'actor_view_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\Actor::class, 'ActorShowNickname'], options: ['is_system_path' => false]); } } diff --git a/src/Routes/Subscribers.php b/src/Routes/Subscribers.php index 1f6c2861d1..a3ee7f1dc0 100644 --- a/src/Routes/Subscribers.php +++ b/src/Routes/Subscribers.php @@ -20,7 +20,7 @@ // }}} /** - * Define social's GSActor's subscribers routes + * Define social's Actor's subscribers routes * * @package GNUsocial * @category Router diff --git a/src/Routes/Subscriptions.php b/src/Routes/Subscriptions.php index 596c5b678a..f73ff0a363 100644 --- a/src/Routes/Subscriptions.php +++ b/src/Routes/Subscriptions.php @@ -20,7 +20,7 @@ // }}} /** - * Define social's GSActor's subscriptions routes + * Define social's Actor's subscriptions routes * * @package GNUsocial * @category Router diff --git a/src/Util/Common.php b/src/Util/Common.php index 6b89580297..494e6d7a59 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -34,7 +34,7 @@ namespace App\Util; use App\Core\Router\Router; use App\Core\Security; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Entity\LocalUser; use App\Util\Exception\NoLoggedInUser; use Functional as F; @@ -111,7 +111,7 @@ abstract class Common return Security::getUser(); } - public static function actor(): ?GSActor + public static function actor(): ?Actor { return self::user()->getActor(); } diff --git a/src/Util/Exception/EmailTakenException.php b/src/Util/Exception/EmailTakenException.php index 0be462a384..eadfa0ef00 100644 --- a/src/Util/Exception/EmailTakenException.php +++ b/src/Util/Exception/EmailTakenException.php @@ -33,13 +33,13 @@ namespace App\Util\Exception; use function App\Core\I18n\_m; -use App\Entity\GSActor; +use App\Entity\Actor; class EmailTakenException extends EmailException { - public ?GSActor $profile = null; // the GSActor which occupies the email + public ?Actor $profile = null; // the Actor which occupies the email - public function __construct(?GSActor $profile = null, ?string $msg = null, int $code = 400) + public function __construct(?Actor $profile = null, ?string $msg = null, int $code = 400) { $this->profile = $profile; parent::__construct($msg, $code); diff --git a/src/Util/Exception/NicknameTakenException.php b/src/Util/Exception/NicknameTakenException.php index bb47a46179..e50a0abe54 100644 --- a/src/Util/Exception/NicknameTakenException.php +++ b/src/Util/Exception/NicknameTakenException.php @@ -42,13 +42,13 @@ namespace App\Util\Exception; use function App\Core\I18n\_m; -use App\Entity\GSActor; +use App\Entity\Actor; class NicknameTakenException extends NicknameException { - public ?GSActor $profile = null; // the GSActor which occupies the nickname + public ?Actor $profile = null; // the Actor which occupies the nickname - public function __construct(?GSActor $profile = null, ?string $msg = null, int $code = 400) + public function __construct(?Actor $profile = null, ?string $msg = null, int $code = 400) { $this->profile = $profile; parent::__construct($msg, $code); diff --git a/src/Util/Form/ActorArrayTransformer.php b/src/Util/Form/ActorArrayTransformer.php index 991596f245..69d07c27a2 100644 --- a/src/Util/Form/ActorArrayTransformer.php +++ b/src/Util/Form/ActorArrayTransformer.php @@ -32,12 +32,12 @@ namespace App\Util\Form; -use App\Entity\GSActor; +use App\Entity\Actor; class ActorArrayTransformer extends ArrayTransformer { /** - * Transforms array of GSActors into string of usernames + * Transforms array of Actors into string of nicknames * * @param array $a * @@ -52,7 +52,7 @@ class ActorArrayTransformer extends ArrayTransformer } /** - * Transforms string of usernames into GSActors + * Transforms string of nicknames into Actors * * @param string $s * @@ -61,7 +61,7 @@ class ActorArrayTransformer extends ArrayTransformer public function reverseTransform($s) { return array_map( - function ($nickmame) { return GSActor::getFromNickname($nickmame); }, + function ($nickmame) { return Actor::getFromNickname($nickmame); }, parent::reverseTransform($s) ); } diff --git a/src/Util/Formatting.php b/src/Util/Formatting.php index 49d25eaf32..46e8b3e87a 100644 --- a/src/Util/Formatting.php +++ b/src/Util/Formatting.php @@ -33,8 +33,8 @@ namespace App\Util; use App\Core\Event; use App\Core\Log; use App\Core\Router\Router; +use App\Entity\Actor; use App\Entity\Group; -use App\Entity\GSActor; use App\Entity\Note; use App\Util\Exception\NicknameException; use App\Util\Exception\ServerException; @@ -527,14 +527,14 @@ abstract class Formatting * Note the return data format is internal, to be used for building links and * such. Should not be used directly; rather, call common_linkify_mentions(). * - * @param string $text - * @param GSActor $actor the GSActor that is sending the current text - * @param Note $parent the Note this text is in reply to, if any + * @param string $text + * @param Actor $actor the Actor that is sending the current text + * @param Note $parent the Note this text is in reply to, if any * * @return array * */ - public static function findMentions(string $text, GSActor $actor, Note $parent = null) + public static function findMentions(string $text, Actor $actor, Note $parent = null) { $mentions = []; if (Event::handle('StartFindMentions', [$actor, $text, &$mentions])) { @@ -583,7 +583,7 @@ abstract class Formatting $mentioned = $actor->findRelativeActor($nickname); } - if ($mentioned instanceof GSActor) { + if ($mentioned instanceof Actor) { $url = $mentioned->getUri(); // prefer the URI as URL, if it is one. if (!Common::isValidHttpUrl($url)) { $url = $mentioned->getUrl(); @@ -697,13 +697,13 @@ abstract class Formatting * * Should generally not be called except from common_render_content(). * - * @param string $text partially-rendered HTML - * @param GSActor $author the GSActor that is composing the current notice - * @param Note $parent the Note this is sent in reply to, if any + * @param string $text partially-rendered HTML + * @param Actor $author the Actor that is composing the current notice + * @param Note $parent the Note this is sent in reply to, if any * * @return string partially-rendered HTML */ - public static function linkifyMentions($text, GSActor $author, ?Note $parent = null) + public static function linkifyMentions($text, Actor $author, ?Note $parent = null) { $mentions = self::findMentions($text, $author, $parent); diff --git a/src/Util/Notification/Notification.php b/src/Util/Notification/Notification.php index 8c4743ded7..9fbdbba998 100644 --- a/src/Util/Notification/Notification.php +++ b/src/Util/Notification/Notification.php @@ -30,7 +30,7 @@ namespace App\Util\Notification; -use App\Entity\GSActor; +use App\Entity\Actor; class Notification { @@ -50,11 +50,11 @@ class Notification /** * Who caused this notification */ - private GSActor $gsactor; + private Actor $actor; - public function __construct(int $type, GSActor $gsactor) + public function __construct(int $type, Actor $actor) { - $this->type = $type; - $this->gsactor = $gsactor; + $this->type = $type; + $this->actor = $actor; } } diff --git a/templates/actor/view.html.twig b/templates/actor/view.html.twig index c0937fdf0d..02bc6b373f 100644 --- a/templates/actor/view.html.twig +++ b/templates/actor/view.html.twig @@ -1,10 +1,10 @@ {% extends 'stdgrid.html.twig' %} -{% set id = gsactor.id %} -{% set nick = gsactor.nickname %} +{% set id = actor.id %} +{% set nick = actor.nickname %} {# TODO: how to get avatar in here? Tags and rest of profile info? #} -{% set avatar = gsactor.nickname %} +{% set avatar = actor.nickname %} {% block title %}{{ nick }}'s profile{% endblock %} diff --git a/tests/Core/DB/DBTest.php b/tests/Core/DB/DBTest.php index 4154702362..caf18be431 100644 --- a/tests/Core/DB/DBTest.php +++ b/tests/Core/DB/DBTest.php @@ -20,7 +20,7 @@ namespace App\Tests\Core\DB; use App\Core\DB\DB; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Entity\LocalUser; use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\NotFoundException; @@ -34,51 +34,51 @@ class DBTest extends GNUsocialTestCase public function testDql() { static::bootKernel(); - $actor = DB::dql('select a from gsactor a where a.nickname = :nickname', ['nickname' => 'taken_user']); + $actor = DB::dql('select a from actor a where a.nickname = :nickname', ['nickname' => 'taken_user']); static::assertTrue(is_array($actor)); - static::assertTrue($actor[0] instanceof GSActor); + static::assertTrue($actor[0] instanceof Actor); } public function testSql() { static::bootKernel(); - $actor = DB::sql('select {select} from gsactor a where a.nickname = :nickname', ['a' => 'App\Entity\GSActor'], ['nickname' => 'taken_user']); + $actor = DB::sql('select {select} from actor a where a.nickname = :nickname', ['a' => 'App\Entity\Actor'], ['nickname' => 'taken_user']); static::assertTrue(is_array($actor)); - static::assertTrue($actor[0] instanceof GSActor); + static::assertTrue($actor[0] instanceof Actor); } public function testFindBy() { static::bootKernel(); - $actor = DB::findBy('gsactor', ['nickname' => 'taken_user']); + $actor = DB::findBy('actor', ['nickname' => 'taken_user']); static::assertTrue(is_array($actor)); - static::assertTrue($actor[0] instanceof GSActor); + static::assertTrue($actor[0] instanceof Actor); - $actor = DB::findBy('gsactor', ['and' => ['is_null' => 'bio', 'or' => ['nickname' => 'user does not exist', 'gte' => ['id' => 0]]]]); + $actor = DB::findBy('actor', ['and' => ['is_null' => 'bio', 'or' => ['nickname' => 'user does not exist', 'gte' => ['id' => 0]]]]); static::assertTrue(is_array($actor)); - static::assertTrue($actor[0] instanceof GSActor); + static::assertTrue($actor[0] instanceof Actor); } public function testFindOneBy() { static::bootKernel(); - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); - static::assertTrue($actor instanceof GSActor); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); + static::assertTrue($actor instanceof Actor); - static::assertThrows(DuplicateFoundException::class, fn () => DB::findOneBy('gsactor', ['is_null' => 'bio'])); - static::assertThrows(NotFoundException::class, fn () => DB::findOneBy('gsactor', ['nickname' => 'nickname_not_in_use'])); + static::assertThrows(DuplicateFoundException::class, fn () => DB::findOneBy('actor', ['is_null' => 'bio'])); + static::assertThrows(NotFoundException::class, fn () => DB::findOneBy('actor', ['nickname' => 'nickname_not_in_use'])); } public function testCount() { static::bootKernel(); - static::assertTrue(DB::count('gsactor', ['nickname' => 'taken_user']) == 1); - static::assertTrue(DB::count('gsactor', []) != 1); + static::assertTrue(DB::count('actor', ['nickname' => 'taken_user']) == 1); + static::assertTrue(DB::count('actor', []) != 1); } public function testPersistWithSameId() { - $actor = GSActor::create(['nickname' => 'test', 'normalized_nickname' => 'test']); + $actor = Actor::create(['nickname' => 'test', 'normalized_nickname' => 'test']); $user = LocalUser::create(['nickname' => 'test']); $id = DB::persistWithSameId($actor, $user, fn ($id) => $id); static::assertTrue($id != 0); diff --git a/tests/Core/DB/UpdateListenerTest.php b/tests/Core/DB/UpdateListenerTest.php index 17a10b19a4..a4580c2e33 100644 --- a/tests/Core/DB/UpdateListenerTest.php +++ b/tests/Core/DB/UpdateListenerTest.php @@ -31,7 +31,7 @@ class UpdateListenerTest extends GNUsocialTestCase public function testPreUpdateExists() { static::bootKernel(); - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); $date = new DateTime('1999-09-23'); $actor->setModified($date); static::assertSame($actor->getModified(), $date); diff --git a/tests/Core/FormTest.php b/tests/Core/FormTest.php index 06279958a6..e39a7a5003 100644 --- a/tests/Core/FormTest.php +++ b/tests/Core/FormTest.php @@ -23,7 +23,7 @@ namespace App\Tests\Core; use App\Core\DB\DB; use App\Core\Form; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Util\Exception\ServerException; use App\Util\Form\ArrayTransformer; use App\Util\GNUsocialTestCase; @@ -93,7 +93,7 @@ class FormTest extends GNUsocialTestCase public function testCreateUpdateObject() { $nick = 'form_testing_new_user'; - $user = GSActor::create(['nickname' => $nick, 'normalized_nickname' => $nick]); + $user = Actor::create(['nickname' => $nick, 'normalized_nickname' => $nick]); $form = Form::create([ ['nickname', TextareaType::class, []], ['normalized_nickname', TextareaType::class, []], @@ -116,7 +116,7 @@ class FormTest extends GNUsocialTestCase $ret = Form::handle(form_definition: [/* not normal usage */], request: $mock_request, target: null, extra_args: [], extra_step: null, create_args: [], testing_only_form: $mock_form); static::assertSame($data, $ret); - $user = GSActor::create(['nickname' => 'form_testing_new_user', 'normalized_nickname' => 'form_testing_new_user']); + $user = Actor::create(['nickname' => 'form_testing_new_user', 'normalized_nickname' => 'form_testing_new_user']); DB::persist($user); $ret = Form::handle(form_definition: [/* not normal usage */], request: $mock_request, target: $user, extra_args: [], extra_step: null, create_args: [], testing_only_form: $mock_form); static::assertSame($mock_form, $ret); diff --git a/tests/Entity/GSActorTest.php b/tests/Entity/ActorTest.php similarity index 79% rename from tests/Entity/GSActorTest.php rename to tests/Entity/ActorTest.php index b1ef258b67..1766b53590 100644 --- a/tests/Entity/GSActorTest.php +++ b/tests/Entity/ActorTest.php @@ -20,34 +20,34 @@ namespace App\Tests\Entity; use App\Core\DB\DB; -use App\Entity\GSActor; -use App\Entity\GSActorTag; +use App\Entity\Actor; +use App\Entity\ActorTag; use App\Util\GNUsocialTestCase; use Functional as F; use Jchook\AssertThrows\AssertThrows; -class GSActorTest extends GNUsocialTestCase +class ActorTest extends GNUsocialTestCase { use AssertThrows; public function testGetAvatarUrl() { - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); static::assertSame("/{$actor->getId()}/avatar", $actor->getAvatarUrl()); } public function testGetFromNickname() { - static::assertNotNull(GSActor::getFromNickname('taken_user')); + static::assertNotNull(Actor::getFromNickname('taken_user')); } public function testSelfTags() { - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); $tags = $actor->getSelfTags(); $actor->setSelfTags(['foo'], $tags); DB::flush(); - $get_tags = fn ($tags) => F\map($tags, fn (GSActorTag $t) => (string) $t); + $get_tags = fn ($tags) => F\map($tags, fn (ActorTag $t) => (string) $t); static::assertSame(['foo'], $get_tags($tags = $actor->getSelfTags())); $actor->setSelfTags(['bar'], $tags); DB::flush(); diff --git a/tests/Entity/AttachmentTest.php b/tests/Entity/AttachmentTest.php index af28c0d2cf..0437d94959 100644 --- a/tests/Entity/AttachmentTest.php +++ b/tests/Entity/AttachmentTest.php @@ -102,8 +102,8 @@ class AttachmentTest extends GNUsocialTestCase static::assertSame('Untitled attachment', $attachment->getBestTitle()); $attachment->setFilename($filename); - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); - DB::persist($note = Note::create(['gsactor_id' => $actor->getId(), 'content' => 'some content'])); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); + DB::persist($note = Note::create(['actor_id' => $actor->getId(), 'content' => 'some content'])); DB::persist(AttachmentToNote::create(['attachment_id' => $attachment->getId(), 'note_id' => $note->getId(), 'title' => 'A title'])); DB::flush(); diff --git a/tests/Entity/GroupTest.php b/tests/Entity/GroupTest.php index af2abc14f4..c61ff12ffe 100644 --- a/tests/Entity/GroupTest.php +++ b/tests/Entity/GroupTest.php @@ -30,7 +30,7 @@ class GroupTest extends GNUsocialTestCase public function testGetActor() { $group = DB::findOneBy('local_group', ['nickname' => 'taken_group']); - $actor = DB::findOneBy('gsactor', ['nickname' => 'taken_group']); + $actor = DB::findOneBy('actor', ['nickname' => 'taken_group']); static::assertSame($actor, $group->getActor()); } } diff --git a/tests/Entity/NoteTest.php b/tests/Entity/NoteTest.php index d6a88a4c12..79d6035d26 100644 --- a/tests/Entity/NoteTest.php +++ b/tests/Entity/NoteTest.php @@ -31,10 +31,10 @@ class NoteTest extends GNUsocialTestCase public function testGetReplies() { $user = DB::findOneBy('local_user', ['nickname' => 'taken_user']); - $note = DB::findBy('note', ['gsactor_id' => $user->getId(), 'content' => 'some content', 'reply_to' => null], limit: 1)[0]; + $note = DB::findBy('note', ['actor_id' => $user->getId(), 'content' => 'some content', 'reply_to' => null], limit: 1)[0]; $replies = $note->getReplies(); static::assertSame('some other content', $replies[0]->getContent()); - static::assertSame($user->getId(), $replies[0]->getGSActorId()); + static::assertSame($user->getId(), $replies[0]->getActorId()); static::assertSame($note->getId(), $replies[0]->getReplyTo()); static::assertSame($user->getNickname(), $replies[0]->getReplyToNickname()); @@ -42,21 +42,21 @@ class NoteTest extends GNUsocialTestCase public function testIsVisibleTo() { - $actor1 = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); - $actor2 = DB::findOneBy('gsactor', ['nickname' => 'taken_group']); - $actor3 = DB::findOneBy('gsactor', ['nickname' => 'some_user']); + $actor1 = DB::findOneBy('actor', ['nickname' => 'taken_user']); + $actor2 = DB::findOneBy('actor', ['nickname' => 'taken_group']); + $actor3 = DB::findOneBy('actor', ['nickname' => 'some_user']); - $note_visible_to_1 = DB::findBy('note', ['gsactor_id' => $actor1->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER], limit: 1)[0]; + $note_visible_to_1 = DB::findBy('note', ['actor_id' => $actor1->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER], limit: 1)[0]; static::assertTrue($note_visible_to_1->isVisibleTo($actor1)); static::assertFalse($note_visible_to_1->isVisibleTo($actor2)); static::assertFalse($note_visible_to_1->isVisibleTo($actor3)); - $note_public = DB::findBy('note', ['gsactor_id' => $actor1->getId(), 'content' => 'some content', 'reply_to' => null], limit: 1)[0]; + $note_public = DB::findBy('note', ['actor_id' => $actor1->getId(), 'content' => 'some content', 'reply_to' => null], limit: 1)[0]; static::assertTrue($note_public->isVisibleTo($actor1)); static::assertTrue($note_public->isVisibleTo($actor2)); static::assertTrue($note_public->isVisibleTo($actor3)); - $group_note = DB::findBy('note', ['gsactor_id' => $actor1->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP], limit: 1)[0]; + $group_note = DB::findBy('note', ['actor_id' => $actor1->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP], limit: 1)[0]; static::assertTrue($group_note->isVisibleTo($actor3)); static::assertFalse($group_note->isVisibleTo($actor2)); static::assertFalse($group_note->isVisibleTo($actor1)); diff --git a/tests/Util/CommonTest.php b/tests/Util/CommonTest.php index a1512436a8..c2ba497da0 100644 --- a/tests/Util/CommonTest.php +++ b/tests/Util/CommonTest.php @@ -21,7 +21,7 @@ namespace App\Tests\Util; use App\Core\DB\DB; use App\Core\Security; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Entity\LocalUser; use App\Util\Common; use App\Util\Exception\NoLoggedInUser; @@ -86,11 +86,11 @@ class CommonTest extends GNUsocialTestCase static::assertFalse(Common::isLoggedIn()); $metadata = $this->createMock(ClassMetadataInfo::class); - $metadata->method('getTableName')->willReturn('gsactor'); - $metadata->method('getMetadataValue')->willReturn('App\Entity\GSActor'); + $metadata->method('getTableName')->willReturn('actor'); + $metadata->method('getMetadataValue')->willReturn('App\Entity\Actor'); $factory = $this->createMock(ClassMetadataFactory::class); $factory->method('getAllMetadata')->willReturn([$metadata]); - $actor = GSActor::create(['nickname' => 'nick']); + $actor = Actor::create(['nickname' => 'nick']); $actor->setId(0); $em = $this->createMock(EntityManager::class); $em->method('find')->willReturn($actor); diff --git a/tests/Util/Form/ActorArrayTransformerTest.php b/tests/Util/Form/ActorArrayTransformerTest.php index d49b911818..9f4050e42f 100644 --- a/tests/Util/Form/ActorArrayTransformerTest.php +++ b/tests/Util/Form/ActorArrayTransformerTest.php @@ -19,7 +19,7 @@ namespace App\Tests\Util\Form; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Util\Form\ActorArrayTransformer; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -29,9 +29,9 @@ class ActorArrayTransformerTest extends WebTestCase { static::assertSame('', (new ActorArrayTransformer)->transform([])); - $user1 = GSActor::create(['nickname' => 'user1']); - $user2 = GSActor::create(['nickname' => 'user2']); - $user3 = GSActor::create(['nickname' => 'user3']); + $user1 = Actor::create(['nickname' => 'user1']); + $user2 = Actor::create(['nickname' => 'user2']); + $user3 = Actor::create(['nickname' => 'user3']); $testArr = [$user1, $user2, $user3]; diff --git a/tests/Util/Notification/NotificationTest.php b/tests/Util/Notification/NotificationTest.php index 164fac15cb..9ab87bd185 100644 --- a/tests/Util/Notification/NotificationTest.php +++ b/tests/Util/Notification/NotificationTest.php @@ -19,7 +19,7 @@ namespace App\Tests\Util\Notification; -use App\Entity\GSActor; +use App\Entity\Actor; use App\Util\Notification\Notification; use Jchook\AssertThrows\AssertThrows; use PHPUnit\Framework\TestCase; @@ -30,6 +30,6 @@ class NotificationTest extends TestCase public function testNotificationBitmap() { - static::assertTrue((new Notification(Notification::DM, new GSActor())) instanceof Notification); + static::assertTrue((new Notification(Notification::DM, new Actor())) instanceof Notification); } }