Browse Source

[Actor] Refactor GSActor into Actor

v3
parent
commit
941cbe6599
Signed by: diogo <mail@diogo.site> GPG Key ID: 18D2D35001FBFAB0
73 changed files with 489 additions and 484 deletions
  1. +1
    -1
      bin/generate_entity_diagrams
  2. +1
    -1
      bin/generate_entity_fields
  3. +26
    -26
      components/Avatar/Avatar.php
  4. +8
    -8
      components/Avatar/Controller/Avatar.php
  5. +8
    -8
      components/Avatar/Entity/Avatar.php
  6. +5
    -5
      components/Posting/Posting.php
  7. +1
    -1
      docs/developer/src/cache.md
  8. +4
    -4
      plugins/ActivityStreamsTwo/ActivityStreamsTwo.php
  9. +5
    -4
      plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php
  10. +6
    -5
      plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php
  11. +4
    -4
      plugins/Cover/Controller/Cover.php
  12. +1
    -1
      plugins/Cover/Cover.php
  13. +8
    -8
      plugins/Cover/Entity/Cover.php
  14. +1
    -1
      plugins/Directory/Controller/Directory.php
  15. +3
    -3
      plugins/Favourite/Controller/Favourite.php
  16. +11
    -11
      plugins/Favourite/Entity/Favourite.php
  17. +1
    -1
      plugins/Favourite/Favourite.php
  18. +2
    -2
      plugins/FileQuota/FileQuota.php
  19. +1
    -1
      plugins/Poll/Controller/AnswerPoll.php
  20. +2
    -2
      plugins/Poll/Controller/NewPoll.php
  21. +13
    -13
      plugins/Poll/Entity/Poll.php
  22. +17
    -17
      plugins/Poll/Entity/PollResponse.php
  23. +1
    -1
      plugins/Poll/Poll.php
  24. +2
    -2
      plugins/ProfileColor/Controller/ProfileColor.php
  25. +10
    -10
      plugins/ProfileColor/Entity/ProfileColor.php
  26. +1
    -1
      plugins/ProfileColor/ProfileColor.php
  27. +7
    -7
      plugins/Repeat/Repeat.php
  28. +14
    -14
      src/Controller/Actor.php
  29. +4
    -4
      src/Controller/Network.php
  30. +25
    -24
      src/Controller/Security.php
  31. +13
    -13
      src/Controller/Subscribers.php
  32. +13
    -13
      src/Controller/Subscriptions.php
  33. +4
    -4
      src/Controller/UserPanel.php
  34. +7
    -7
      src/DataFixtures/CoreFixtures.php
  35. +6
    -6
      src/Entity/Activity.php
  36. +16
    -16
      src/Entity/Actor.php
  37. +5
    -5
      src/Entity/ActorBlock.php
  38. +9
    -9
      src/Entity/ActorCircle.php
  39. +8
    -8
      src/Entity/ActorTag.php
  40. +19
    -19
      src/Entity/ActorTagFollow.php
  41. +10
    -10
      src/Entity/ActorToAttachment.php
  42. +2
    -2
      src/Entity/Follow.php
  43. +2
    -2
      src/Entity/FollowQueue.php
  44. +14
    -14
      src/Entity/Group.php
  45. +10
    -10
      src/Entity/GroupBlock.php
  46. +10
    -10
      src/Entity/GroupJoinQueue.php
  47. +16
    -16
      src/Entity/GroupMember.php
  48. +1
    -1
      src/Entity/Link.php
  49. +1
    -1
      src/Entity/LocalGroup.php
  50. +3
    -3
      src/Entity/LocalUser.php
  51. +27
    -25
      src/Entity/Note.php
  52. +10
    -10
      src/Entity/Notification.php
  53. +7
    -7
      src/Entity/UserNotificationPrefs.php
  54. +3
    -3
      src/Routes/Actor.php
  55. +1
    -1
      src/Routes/Subscribers.php
  56. +1
    -1
      src/Routes/Subscriptions.php
  57. +2
    -2
      src/Util/Common.php
  58. +3
    -3
      src/Util/Exception/EmailTakenException.php
  59. +3
    -3
      src/Util/Exception/NicknameTakenException.php
  60. +4
    -4
      src/Util/Form/ActorArrayTransformer.php
  61. +10
    -10
      src/Util/Formatting.php
  62. +5
    -5
      src/Util/Notification/Notification.php
  63. +3
    -3
      templates/actor/view.html.twig
  64. +16
    -16
      tests/Core/DB/DBTest.php
  65. +1
    -1
      tests/Core/DB/UpdateListenerTest.php
  66. +3
    -3
      tests/Core/FormTest.php
  67. +7
    -7
      tests/Entity/ActorTest.php
  68. +2
    -2
      tests/Entity/AttachmentTest.php
  69. +1
    -1
      tests/Entity/GroupTest.php
  70. +8
    -8
      tests/Entity/NoteTest.php
  71. +4
    -4
      tests/Util/CommonTest.php
  72. +4
    -4
      tests/Util/Form/ActorArrayTransformerTest.php
  73. +2
    -2
      tests/Util/Notification/NotificationTest.php

+ 1
- 1
bin/generate_entity_diagrams View File

@@ -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}";
}
}


+ 1
- 1
bin/generate_entity_fields View File

@@ -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') {


+ 26
- 26
components/Avatar/Avatar.php View File

@@ -38,7 +38,7 @@ class Avatar extends Component

public function onAddRoute($r): bool
{
$r->connect('avatar', '/actor/{gsactor_id<\d+>}/avatar/{size<full|big|medium|small>?full}', [Controller\Avatar::class, 'avatar_view']);
$r->connect('avatar', '/actor/{actor_id<\d+>}/avatar/{size<full|big|medium|small>?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


+ 8
- 8
components/Avatar/Controller/Avatar.php View File

@@ -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()]);
}


+ 8
- 8
components/Avatar/Entity/Avatar.php View File

@@ -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'],
],


+ 5
- 5
components/Posting/Posting.php View File

@@ -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);


+ 1
- 1
docs/developer/src/cache.md View File

@@ -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


+ 4
- 4
plugins/ActivityStreamsTwo/ActivityStreamsTwo.php View File

@@ -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;


+ 5
- 4
plugins/ActivityStreamsTwo/Util/Model/EntityToType/GSActorToType.php View File

@@ -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 = [


+ 6
- 5
plugins/ActivityStreamsTwo/Util/Response/ActorResponse.php View File

@@ -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);


+ 4
- 4
plugins/Cover/Controller/Cover.php View File

@@ -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);
// }


+ 1
- 1
plugins/Cover/Cover.php View File

@@ -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 {


+ 8
- 8
plugins/Cover/Entity/Cover.php View File

@@ -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'],
],


+ 1
- 1
plugins/Directory/Controller/Directory.php View File

@@ -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')];
}

/**


+ 3
- 3
plugins/Favourite/Controller/Favourite.php View File

@@ -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]
);


+ 11
- 11
plugins/Favourite/Entity/Favourite.php View File

@@ -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'],
],
];


+ 1
- 1
plugins/Favourite/Favourite.php View File

@@ -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,


+ 2
- 2
plugins/FileQuota/FileQuota.php View File

@@ -65,8 +65,8 @@ class FileQuota extends Plugin
$query = <<<END
select sum(at.size) as total
from attachment at
join gsactor_to_attachment ua with at.id = ua.attachment_id
where ua.gsactor_id = :actor_id and at.size is not null
join actor_to_attachment ua with at.id = ua.attachment_id
where ua.actor_id = :actor_id and at.size is not null
END;

$max_file_size = Common::config('attachments', 'file_quota');


+ 1
- 1
plugins/Poll/Controller/AnswerPoll.php View File

@@ -82,7 +82,7 @@ class AnswerPoll
if (PollResponse::exits($poll->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();



+ 2
- 2
plugins/Poll/Controller/NewPoll.php View File

@@ -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');


+ 13
- 13
plugins/Poll/Entity/Poll.php View File

@@ -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' => [


+ 17
- 17
plugins/Poll/Entity/PollResponse.php View File

@@ -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;
}
}

+ 1
- 1
plugins/Poll/Poll.php View File

@@ -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();



+ 2
- 2
plugins/ProfileColor/Controller/ProfileColor.php View File

@@ -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();


+ 10
- 10
plugins/ProfileColor/Entity/ProfileColor.php View File

@@ -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'],
];
}
}

+ 1
- 1
plugins/ProfileColor/ProfileColor.php View File

@@ -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()]];
}


+ 7
- 7
plugins/Repeat/Repeat.php View File

@@ -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();



src/Controller/GSActor.php → src/Controller/Actor.php View File

@@ -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]);
}
}

+ 4
- 4
src/Controller/Network.php View File

@@ -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;


+ 25
- 24
src/Controller/Security.php View File

@@ -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'],


+ 13
- 13
src/Controller/Subscribers.php View File

@@ -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]);
}
}

+ 13
- 13
src/Controller/Subscriptions.php View File

@@ -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]);
}
}

+ 4
- 4
src/Controller/UserPanel.php View File

@@ -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;


+ 7
- 7
src/DataFixtures/CoreFixtures.php View File

@@ -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();
}


+ 6
- 6
src/Entity/Activity.php View File

@@ -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'],


src/Entity/GSActor.php → src/Entity/Actor.php View File

@@ -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'],
],
];


src/Entity/GSActorBlock.php → src/Entity/ActorBlock.php View File

@@ -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'],

src/Entity/GSActorCircle.php → src/Entity/ActorCircle.php View File

@@ -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'],
],
];
}

src/Entity/GSActorTag.php → src/Entity/ActorTag.php View File

@@ -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'],
],
];
}

src/Entity/GSActorTagFollow.php → src/Entity/ActorTagFollow.php View File

@@ -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'],
],
];
}

src/Entity/GSActorToAttachment.php → src/Entity/ActorToAttachment.php View File

@@ -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'],
],
];
}

+ 2
- 2
src/Entity/Follow.php View File

@@ -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'],
],


+ 2
- 2
src/Entity/FollowQueue.php View File

@@ -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'],


+ 14
- 14
src/Entity/Group.php View File

@@ -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'],
],
];
}


+ 10
- 10
src/Entity/GroupBlock.php View File

@@ -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'],
];
}
}

+ 10
- 10
src/Entity/GroupJoinQueue.php View File

@@ -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'],
],
];
}


+ 16
- 16
src/Entity/GroupMember.php View File

@@ -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;