[Actor] Refactor GSActor into Actor

This commit is contained in:
Diogo Peralta Cordeiro 2021-09-18 03:22:27 +01:00
parent 6c899b7b61
commit 941cbe6599
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
73 changed files with 489 additions and 484 deletions

View File

@ -51,7 +51,7 @@ foreach ($files as $file) {
foreach ($schema['fields'] as $field => $opts) { foreach ($schema['fields'] as $field => $opts) {
if (isset($opts['foreign key'])) { if (isset($opts['foreign key'])) {
[$foreign_entity, $foreign_key] = explode('.', $opts['target']); [$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}"; $edges[] = "{$table}:{$field} -- {$foreign_table}:{$foreign_key}";
} }
} }

View File

@ -50,7 +50,7 @@ foreach ($files as $file) {
$nullable = !@$schema['fields'][$field]['not null'] ? '?' : ''; $nullable = !@$schema['fields'][$field]['not null'] ? '?' : '';
$type = types[$schema['fields'][$field]['type']]; $type = types[$schema['fields'][$field]['type']];
$type = $type !== '' ? $nullable . $type : $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']; $default = @$schema['fields'][$field]['default'];
if (isset($default) && $nullable != '?' && $type != '\DateTimeInterface') { if (isset($default) && $nullable != '?' && $type != '\DateTimeInterface') {

View File

@ -38,7 +38,7 @@ class Avatar extends Component
public function onAddRoute($r): bool 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']); $r->connect('settings_avatar', '/settings/avatar', [Controller\Avatar::class, 'settings_avatar']);
return Event::next; return Event::next;
} }
@ -63,64 +63,64 @@ class Avatar extends Component
return Event::next; 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; 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-' . $actor_id);
Cache::delete('avatar-url-' . $gsactor_id); Cache::delete('avatar-url-' . $actor_id);
Cache::delete('avatar-file-info-' . $gsactor_id); Cache::delete('avatar-file-info-' . $actor_id);
return Event::next; return Event::next;
} }
// UTILS ---------------------------------- // 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, return GSFile::error(NoAvatarException::class,
$gsactor_id, $actor_id,
Cache::get("avatar-{$gsactor_id}", Cache::get("avatar-{$actor_id}",
function () use ($gsactor_id) { function () use ($actor_id) {
return DB::dql('select a from Component\Avatar\Entity\Avatar a ' . return DB::dql('select a from Component\Avatar\Entity\Avatar a ' .
'where a.gsactor_id = :gsactor_id', 'where a.actor_id = :actor_id',
['gsactor_id' => $gsactor_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(); $actor_id = $actor_id ?: Common::userId();
return Cache::get("avatar-url-{$gsactor_id}", function () use ($gsactor_id) { return Cache::get("avatar-url-{$actor_id}", function () use ($actor_id) {
return Router::url('avatar', ['gsactor_id' => $gsactor_id, 'size' => 'full']); 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. * Returns the avatar file's hash, mimetype, title and path.
* Ensures exactly one cached value exists * 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}", $res = Cache::get("avatar-file-info-{$actor_id}",
function () use ($gsactor_id) { function () use ($actor_id) {
return DB::dql('select f.id, f.filename, a.filename title, f.mimetype ' . return DB::dql('select f.id, f.filename, a.filename title, f.mimetype ' .
'from App\Entity\Attachment f ' . 'from App\Entity\Attachment f ' .
'join Component\Avatar\Entity\Avatar a with f.id = a.attachment_id ' . 'join Component\Avatar\Entity\Avatar a with f.id = a.attachment_id ' .
'where a.gsactor_id = :gsactor_id', 'where a.actor_id = :actor_id',
['gsactor_id' => $gsactor_id]); ['actor_id' => $actor_id]);
} }
); );
if ($res === []) { // Avatar not found if ($res === []) { // Avatar not found

View File

@ -48,11 +48,11 @@ class Avatar extends Controller
/** /**
* @throws Exception * @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) { switch ($size) {
case 'full': 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']); return M::sendFile($res['filepath'], $res['mimetype'], $res['title']);
default: default:
throw new Exception('Not implemented'); throw new Exception('Not implemented');
@ -74,12 +74,12 @@ class Avatar extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
$user = Common::user(); $user = Common::user();
$gsactor_id = $user->getId(); $actor_id = $user->getId();
if ($data['remove'] == true) { if ($data['remove'] == true) {
try { try {
$avatar = DB::findOneBy('avatar', ['gsactor_id' => $gsactor_id]); $avatar = DB::findOneBy('avatar', ['actor_id' => $actor_id]);
$avatar->delete(); $avatar->delete();
Event::handle('AvatarUpdate', [$user->getId()]); Event::handle('AvatarUpdate', [$user->getId()]);
} catch (NotFoundException) { } catch (NotFoundException) {
@ -109,12 +109,12 @@ class Avatar extends Controller
throw new ClientException('Invalid form'); throw new ClientException('Invalid form');
} }
// Delete current avatar if there's one // 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(); $avatar?->delete();
DB::persist($attachment); DB::persist($attachment);
// Can only get new id after inserting // Can only get new id after inserting
DB::flush(); 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(); DB::flush();
Event::handle('AvatarUpdate', [$user->getId()]); Event::handle('AvatarUpdate', [$user->getId()]);
} }

View File

@ -46,21 +46,21 @@ class Avatar extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $gsactor_id; private int $actor_id;
private int $attachment_id; private int $attachment_id;
private ?string $filename; private ?string $filename;
private DateTimeInterface $created; private DateTimeInterface $created;
private DateTimeInterface $modified; 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; 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 public function setAttachmentId(int $attachment_id): self
@ -119,7 +119,7 @@ class Avatar extends Entity
public function getUrl(): string 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 public function getAttachment(): Attachment
@ -157,13 +157,13 @@ class Avatar extends Entity
return [ return [
'name' => 'avatar', 'name' => 'avatar',
'fields' => [ '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'], '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'], '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'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
], ],
'primary key' => ['gsactor_id'], 'primary key' => ['actor_id'],
'indexes' => [ 'indexes' => [
'avatar_attachment_id_idx' => ['attachment_id'], 'avatar_attachment_id_idx' => ['attachment_id'],
], ],

View File

@ -27,8 +27,8 @@ use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Entity\Actor;
use App\Entity\Attachment; use App\Entity\Attachment;
use App\Entity\GSActor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
@ -60,7 +60,7 @@ class Posting extends Component
$actor_id = $user->getId(); $actor_id = $user->getId();
$to_tags = []; $to_tags = [];
$tags = Cache::get("actor-circle-{$actor_id}", $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) { foreach ($tags as $t) {
$t = $t['tag']; $t = $t['tag'];
$to_tags[$t] = $t; $to_tags[$t] = $t;
@ -109,12 +109,12 @@ class Posting extends Component
return Event::next; 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; $rendered = null;
Event::handle('RenderNoteContent', [$content, $content_type, &$rendered, $actor, $reply_to]); Event::handle('RenderNoteContent', [$content, $content_type, &$rendered, $actor, $reply_to]);
$note = Note::create([ $note = Note::create([
'gsactor_id' => $actor->getId(), 'actor_id' => $actor->getId(),
'content' => $content, 'content' => $content,
'content_type' => $content_type, 'content_type' => $content_type,
'rendered' => $rendered, 'rendered' => $rendered,
@ -125,7 +125,7 @@ class Posting extends Component
DB::flush(); 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') { if ($content_type === 'text/plain') {
$content = Formatting::renderPlainText($content); $content = Formatting::renderPlainText($content);

View File

@ -22,7 +22,7 @@ Store
```php ```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. * Returns the avatar file's hash, mimetype, title and path.
* Ensures exactly one cached value exists * Ensures exactly one cached value exists

View File

@ -42,19 +42,19 @@ class ActivityStreamsTwo extends Plugin
switch ($route) { switch ($route) {
case 'actor_view_id': case 'actor_view_id':
case 'actor_view_nickname': case 'actor_view_nickname':
$response = ActorResponse::handle($vars['gsactor']); $response = ActorResponse::handle($vars['actor']);
return Event::stop; return Event::stop;
case 'note_view': case 'note_view':
$response = NoteResponse::handle($vars['note']); $response = NoteResponse::handle($vars['note']);
return Event::stop; return Event::stop;
case 'actor_favourites': case 'actor_favourites':
$response = LikeResponse::handle($vars['gsactor']); $response = LikeResponse::handle($vars['actor']);
return Event::stop; return Event::stop;
case 'actor_subscriptions': case 'actor_subscriptions':
$response = FollowingResponse::handle($vars['gsactor']); $response = FollowingResponse::handle($vars['actor']);
return Event::stop; return Event::stop;
case 'actor_subscribers': case 'actor_subscribers':
$response = FollowersResponse::handle($vars['gsactor']); $response = FollowersResponse::handle($vars['actor']);
return Event::stop; return Event::stop;
default: default:
return Event::next; return Event::next;

View File

@ -3,7 +3,7 @@
namespace Plugin\ActivityStreamsTwo\Util\Model\EntityToType; namespace Plugin\ActivityStreamsTwo\Util\Model\EntityToType;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\GSActor; use App\Entity\Actor;
use DateTimeInterface; use DateTimeInterface;
use Exception; use Exception;
use Plugin\ActivityStreamsTwo\Util\Type; use Plugin\ActivityStreamsTwo\Util\Type;
@ -11,13 +11,14 @@ use Plugin\ActivityStreamsTwo\Util\Type;
class GSActorToType class GSActorToType
{ {
/** /**
* @param GSActor $gsactor * @param Actor $gsactor
* *
* @throws Exception *@throws Exception
* *
* @return Type * @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); $uri = Router::url('actor_view_id', ['id' => $gsactor->getId()], Router::ABSOLUTE_URL);
$attr = [ $attr = [

View File

@ -2,21 +2,22 @@
namespace Plugin\ActivityStreamsTwo\Util\Response; namespace Plugin\ActivityStreamsTwo\Util\Response;
use App\Entity\GSActor; use App\Entity\Actor;
use Exception; use Exception;
use Plugin\ActivityStreamsTwo\Util\Model\EntityToType\GSActorToType; use Plugin\ActivityStreamsTwo\Util\Model\EntityToType\GSActorToType;
abstract class ActorResponse abstract class ActorResponse
{ {
/** /**
* @param GSActor $gsactor * @param Actor $gsactor
* @param int $status The response status code * @param int $status The response status code
* *
* @throws Exception *@throws Exception
* *
* @return TypeResponse * @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 $gsactor->getLocalUser(); // This throws exception if not a local user, which is intended
return new TypeResponse(data: GSActorToType::translate($gsactor), status: $status); return new TypeResponse(data: GSActorToType::translate($gsactor), status: $status);

View File

@ -98,7 +98,7 @@ class Cover
} }
$file = GSFile::sanitizeAndStoreFileAsAttachment($sfile); $file = GSFile::sanitizeAndStoreFileAsAttachment($sfile);
$old_file = null; $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 // Must get old id before inserting another one
if ($cover != null) { if ($cover != null) {
$old_file = $cover->delete(); $old_file = $cover->delete();
@ -107,7 +107,7 @@ class Cover
DB::persist($file); DB::persist($file);
// Can only get new id after inserting // Can only get new id after inserting
DB::flush(); 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::persist($cover);
DB::flush(); DB::flush();
// Only delete files if the commit went through // Only delete files if the commit went through
@ -118,7 +118,7 @@ class Cover
} }
$removeForm = null; $removeForm = null;
$cover = DB::find('cover', ['gsactor_id' => $actor_id]); $cover = DB::find('cover', ['actor_id' => $actor_id]);
if ($cover != null) { if ($cover != null) {
$form2 = Form::create([ $form2 = Form::create([
['remove', SubmitType::class, ['label' => _m('Remove')]], ['remove', SubmitType::class, ['label' => _m('Remove')]],
@ -143,7 +143,7 @@ class Cover
*/ */
public function 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) { // if ($cover == null) {
// return new Response('Cover not found',Response::HTTP_NOT_FOUND); // return new Response('Cover not found',Response::HTTP_NOT_FOUND);
// } // }

View File

@ -75,7 +75,7 @@ class Cover extends Plugin
public function onStartTwigPopulateVars(array &$vars): bool public function onStartTwigPopulateVars(array &$vars): bool
{ {
/*if (Common::user() != null) { /*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) { if ($cover != null) {
$vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']]; $vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']];
} else { } else {

View File

@ -41,20 +41,20 @@ class Cover extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $gsactor_id; private int $actor_id;
private int $attachment_id; private int $attachment_id;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; 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; 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 public function setAttachmentId(int $attachment_id): self
@ -131,7 +131,7 @@ class Cover extends Entity
if (!$cascading) { if (!$cascading) {
$attachments = $this->getAttachment()->kill(); $attachments = $this->getAttachment()->kill();
} else { } 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(); $attachment_path = $this->getAttachmentPath();
$attachments[] = $attachment_path; $attachments[] = $attachment_path;
if ($flush) { if ($flush) {
@ -147,12 +147,12 @@ class Cover extends Entity
return [ return [
'name' => 'cover', 'name' => 'cover',
'fields' => [ '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'], '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'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
], ],
'primary key' => ['gsactor_id'], 'primary key' => ['actor_id'],
'indexes' => [ 'indexes' => [
'cover_attachment_id_idx' => ['attachment_id'], 'cover_attachment_id_idx' => ['attachment_id'],
], ],

View File

@ -35,7 +35,7 @@ class Directory
*/ */
public function actors(Request $request) 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')];
} }
/** /**

View File

@ -32,7 +32,7 @@ class Favourite
$notes = DB::dql( $notes = DB::dql(
'select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' . 'select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' .
'where n.id = f.note_id ' . 'where n.id = f.note_id ' .
'and f.gsactor_id = :id ' . 'and f.actor_id = :id ' .
'order by f.created DESC', 'order by f.created DESC',
['id' => $id] ['id' => $id]
); );
@ -64,8 +64,8 @@ class Favourite
{ {
$notes = DB::dql('select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' . $notes = DB::dql('select n from App\Entity\Note n, Plugin\Favourite\Entity\Favourite f ' .
'where n.id = f.note_id ' . 'where n.id = f.note_id ' .
'and f.gsactor_id != :id ' . 'and f.actor_id != :id ' .
'and n.gsactor_id = :id ' . 'and n.actor_id = :id ' .
'order by f.created DESC' , 'order by f.created DESC' ,
['id' => $id] ['id' => $id]
); );

View File

@ -27,7 +27,7 @@ class Favourite extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $note_id; private int $note_id;
private int $gsactor_id; private int $actor_id;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; private \DateTimeInterface $modified;
@ -42,15 +42,15 @@ class Favourite extends Entity
return $this->note_id; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -83,15 +83,15 @@ class Favourite extends Entity
return [ return [
'name' => 'favourite', 'name' => 'favourite',
'fields' => [ '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'], '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 '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'], 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'], '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' => [ 'indexes' => [
'fave_note_id_idx' => ['note_id'], 'fave_note_id_idx' => ['note_id'],
'fave_actor_id_idx' => ['gsactor_id', 'modified'], 'fave_actor_id_idx' => ['actor_id', 'modified'],
'fave_modified_idx' => ['modified'], 'fave_modified_idx' => ['modified'],
], ],
]; ];

View File

@ -61,7 +61,7 @@ class Favourite extends NoteHandlerPlugin
} }
// if note is favoured, "is_set" is 1 // 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; $is_set = DB::find('favourite', $opts) !== null;
$form_fav = Form::create([ $form_fav = Form::create([
['submit_favourite', SubmitType::class, ['submit_favourite', SubmitType::class,

View File

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

View File

@ -82,7 +82,7 @@ class AnswerPoll
if (PollResponse::exits($poll->getId(), $user->getId())) { if (PollResponse::exits($poll->getId(), $user->getId())) {
throw new ServerException('User already responded to poll'); 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::persist($pollResponse);
DB::flush(); DB::flush();

View File

@ -83,7 +83,7 @@ class NewPoll
if ($form->isValid()) { if ($form->isValid()) {
$data = $form->getData(); $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); DB::persist($note);
Security::sanitize($question = $data['Question']); Security::sanitize($question = $data['Question']);
@ -92,7 +92,7 @@ class NewPoll
} }
$options = implode("\n",$opt); $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::persist($poll);
DB::flush(); DB::flush();
throw new RedirectException('root'); throw new RedirectException('root');

View File

@ -41,7 +41,7 @@ class Poll extends Entity
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $id; private int $id;
private ?string $uri; private ?string $uri;
private ?int $gsactor_id; private ?int $actor_id;
private int $note_id; private int $note_id;
private ?string $question; private ?string $question;
private ?string $options; private ?string $options;
@ -70,15 +70,15 @@ class Poll extends Entity
return $this->uri; 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; 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 public function setNoteId(int $note_id): self
@ -150,14 +150,14 @@ class Poll extends Entity
'name' => 'poll', 'name' => 'poll',
'description' => 'Per-notice poll data for Poll plugin', 'description' => 'Per-notice poll data for Poll plugin',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], 'id' => ['type' => 'serial', 'not null' => true],
'uri' => ['type' => 'varchar', 'length' => 191], 'uri' => ['type' => 'varchar', 'length' => 191],
'gsactor_id' => ['type' => 'int'], 'actor_id' => ['type' => 'int'],
'note_id' => ['type' => 'int', 'not null' => true], 'note_id' => ['type' => 'int', 'not null' => true],
'question' => ['type' => 'text'], 'question' => ['type' => 'text'],
'options' => ['type' => 'text'], 'options' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'unique keys' => [ 'unique keys' => [

View File

@ -42,7 +42,7 @@ class PollResponse extends Entity
private int $id; private int $id;
private ?string $uri; private ?string $uri;
private int $poll_id; private int $poll_id;
private ?int $gsactor_id; private ?int $actor_id;
private ?int $selection; private ?int $selection;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; private \DateTimeInterface $modified;
@ -80,15 +80,15 @@ class PollResponse extends Entity
return $this->poll_id; 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; return $this;
} }
public function getGSActorId(): ?int public function getActorId(): ?int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setSelection(?int $selection): self public function setSelection(?int $selection): self
@ -140,25 +140,25 @@ class PollResponse extends Entity
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], 'id' => ['type' => 'serial', 'not null' => true],
//'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'UUID to the response notice'), //'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'], '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'], 'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'],
'gsactor_id' => ['type' => 'int'], 'actor_id' => ['type' => 'int'],
'selection' => ['type' => 'int'], 'selection' => ['type' => 'int'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'unique keys' => [ 'unique keys' => [
//'poll_uri_key' => array('uri'), //'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 keys' => [
'foreign_poll' => ['poll', ['poll_id' => 'id']], 'foreign_poll' => ['poll', ['poll_id' => 'id']],
], ],
'indexes' => [ '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 * Checks if a user already responded to the poll
* *
* @param int $pollId * @param int $pollId
* @param int $gsactorId user * @param int $actorId user
* *
* @return bool * @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 $res = DB::dql('select pr from App\Entity\PollResponse pr
where pr.poll_id = :pollId and pr.gsactor_id = :gsactorId', where pr.poll_id = :pollId and pr.actor_id = :actorId',
['pollId' => $pollId, 'gsactorId' => $gsactorId]); ['pollId' => $pollId, 'actorId' => $actorId]);
return count($res) != 0; return count($res) != 0;
} }
} }

View File

@ -153,7 +153,7 @@ class Poll extends NoteHandlerPlugin
if (Entity\PollResponse::exits($poll->getId(), $user->getId())) { if (Entity\PollResponse::exits($poll->getId(), $user->getId())) {
throw new ServerException('User already responded to poll'); 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::persist($pollResponse);
DB::flush(); DB::flush();

View File

@ -57,7 +57,7 @@ class ProfileColor
{ {
$user = Common::user(); $user = Common::user();
$actor_id = $user->getId(); $actor_id = $user->getId();
$pcolor = DB::find('profile_color', ['gsactor_id' => $actor_id]); $pcolor = DB::find('profile_color', ['actor_id' => $actor_id]);
$color = '#000000'; $color = '#000000';
if ($pcolor != null) { if ($pcolor != null) {
$color = $pcolor->getColor(); $color = $pcolor->getColor();
@ -78,7 +78,7 @@ class ProfileColor
DB::flush(); 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::persist($pcolor);
DB::flush(); DB::flush();
throw new RedirectException(); throw new RedirectException();

View File

@ -38,20 +38,20 @@ class ProfileColor extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $gsactor_id; private int $actor_id;
private string $color; private string $color;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setColor(string $color): self public function setColor(string $color): self
@ -94,12 +94,12 @@ class ProfileColor extends Entity
return [ return [
'name' => 'profile_color', 'name' => 'profile_color',
'fields' => [ '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'],
'color' => ['type' => 'text', 'not null' => true, 'description' => 'color hex code'], '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'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified', 'default' => 'CURRENT_TIMESTAMP'],
], ],
'primary key' => ['gsactor_id'], 'primary key' => ['actor_id'],
]; ];
} }
} }

View File

@ -80,7 +80,7 @@ class ProfileColor extends Plugin
'path' => 'profilecolor/profilecolor.html.twig', 'path' => 'profilecolor/profilecolor.html.twig',
];*/ ];*/
if (Common::user() != null) { 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) { if ($color != null) {
$vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]]; $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]];
} }

View File

@ -22,6 +22,7 @@ namespace Plugin\Repeat;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Form; use App\Core\Form;
use function App\Core\I18n\_m;
use App\Core\Modules\NoteHandlerPlugin; use App\Core\Modules\NoteHandlerPlugin;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; 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\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use function App\Core\I18n\_m;
class Repeat extends NoteHandlerPlugin class Repeat extends NoteHandlerPlugin
{ {
@ -45,7 +45,7 @@ class Repeat extends NoteHandlerPlugin
return Event::next; 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; $is_set = DB::count('note', $opts) == 1;
$form_repeat = Form::create([ $form_repeat = Form::create([
['submit_repeat', SubmitType::class, ['submit_repeat', SubmitType::class,
@ -66,13 +66,13 @@ class Repeat extends NoteHandlerPlugin
$request, $form_repeat, $note, "repeat-{$note->getId()}", function ($note, $data, $user) { $request, $form_repeat, $note, "repeat-{$note->getId()}", function ($note, $data, $user) {
if ($data["repeat-{$note->getId()}"] === '0') { if ($data["repeat-{$note->getId()}"] === '0') {
DB::persist(Note::create([ DB::persist(Note::create([
'gsactor_id' => $user->getId(), 'actor_id' => $user->getId(),
'repeat_of' => $note->getId(), 'repeat_of' => $note->getId(),
'content' => $note->getContent(), 'content' => $note->getContent(),
'is_local' => true, 'is_local' => true,
])); ]));
} else { } 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(); DB::flush();

View File

@ -27,43 +27,43 @@ use function App\Core\I18n\_m;
use App\Util\Exception\ClientException; use App\Util\Exception\ClientException;
use Symfony\Component\HttpFoundation\Request; 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 * 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]); $actor = DB::findOneBy('actor', ['id' => $id]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* Generic function that handles getting a representation for an actor from nickname * 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]); $user = DB::findOneBy('local_user', ['nickname' => $nickname]);
$gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); $actor = DB::findOneBy('actor', ['id' => $user->getId()]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* The page where the actor's info is shown * 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]);
} }
} }

View File

@ -68,7 +68,7 @@ class Network extends Controller
public function home(Request $request, string $nickname) public function home(Request $request, string $nickname)
{ {
try { try {
$target = DB::findOneBy('gsactor', ['nickname' => $nickname]); $target = DB::findOneBy('actor', ['nickname' => $nickname]);
} catch (NotFoundException) { } catch (NotFoundException) {
throw new ClientException(_m('User {nickname} doesn\'t exist', ['{nickname}' => $nickname])); 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 select note.* from note left join -- left join ensures all returned notes' ids are not null
( (
-- Followed by target -- 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 where f.follower = :target_actor_id
union all union all
-- Replies to notes by target -- Replies to notes by target
@ -89,7 +89,7 @@ class Network extends Controller
union all union all
-- Notes in groups target follows -- 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 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 as s on s.id = note.id
where where
@ -125,7 +125,7 @@ END;
{ {
$actor_id = Common::ensureLoggedIn()->getId(); $actor_id = Common::ensureLoggedIn()->getId();
$notes = DB::dql('select n from App\Entity\Note n ' . $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]); 'order by n.created DESC', ['id' => $actor_id]);
$notes_out = null; $notes_out = null;

View File

@ -5,25 +5,24 @@ namespace App\Controller;
use App\Core\Controller; use App\Core\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Form; 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 function App\Core\I18n\_m;
use App\Core\Log; use App\Core\Log;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Actor;
use App\Entity\Follow; use App\Entity\Follow;
use App\Entity\GSActor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Entity\Note; use App\Entity\Note;
use App\Security\Authenticator; use App\Security\Authenticator;
use App\Security\EmailVerifier; use App\Security\EmailVerifier;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\EmailTakenException; use App\Util\Exception\EmailTakenException;
use App\Util\Exception\NicknameEmptyException;
use App\Util\Exception\NicknameReservedException;
use App\Util\Exception\NicknameTakenException; 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\Exception\ServerException;
use App\Util\Form\FormFields; use App\Util\Form\FormFields;
use App\Util\Nickname; 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\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Validator\Constraints\Length; 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.'); 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 * Register a user, making sure the nickname is not reserved and
* possibly sending a confirmation email * possibly sending a confirmation email
* *
* @param Request $request * @param Request $request
* @param GuardAuthenticatorHandler $guard_handler * @param GuardAuthenticatorHandler $guard_handler
* @param Authenticator $authenticator * @param Authenticator $authenticator
* @return array|Response|null *
* @throws EmailTakenException * @throws EmailTakenException
* @throws NicknameTakenException * @throws NicknameTakenException
* @throws ServerException * @throws ServerException
@ -88,10 +87,12 @@ class Security extends Controller
* @throws NicknameTooLongException * @throws NicknameTooLongException
* @throws NicknameTooShortException * @throws NicknameTooShortException
* @throws NotImplementedException * @throws NotImplementedException
*
* @return null|array|Response
*/ */
public function register(Request $request, public function register(Request $request,
GuardAuthenticatorHandler $guard_handler, GuardAuthenticatorHandler $guard_handler,
Authenticator $authenticator) Authenticator $authenticator)
{ {
$form = Form::create([ $form = Form::create([
['nickname', TextType::class, [ ['nickname', TextType::class, [
@ -105,16 +106,16 @@ class Security extends Controller
'max' => Nickname::MAX_LEN, 'max' => Nickname::MAX_LEN,
'maxMessage' => _m(['Your nickname must be at most # characters long'], ['count' => Nickname::MAX_LEN]), ]), 'maxMessage' => _m(['Your nickname must be at most # characters long'], ['count' => Nickname::MAX_LEN]), ]),
], ],
'block_name' => 'nickname', 'block_name' => 'nickname',
'label_attr' => ['class' => 'section-form-label'], 'label_attr' => ['class' => 'section-form-label'],
'invalid_message' => _m('Nickname not valid. Please provide a valid nickname.'), 'invalid_message' => _m('Nickname not valid. Please provide a valid nickname.'),
]], ]],
['email', EmailType::class, [ ['email', EmailType::class, [
'label' => _m('Email'), 'label' => _m('Email'),
'help' => _m('Desired email for this account (e.g., john@provider.com)'), 'help' => _m('Desired email for this account (e.g., john@provider.com)'),
'constraints' => [ new NotBlank(['message' => _m('Please enter an email') ])], 'constraints' => [ new NotBlank(['message' => _m('Please enter an email') ])],
'block_name' => 'email', 'block_name' => 'email',
'label_attr' => ['class' => 'section-form-label'], 'label_attr' => ['class' => 'section-form-label'],
'invalid_message' => _m('Email not valid. Please provide a valid email.'), 'invalid_message' => _m('Email not valid. Please provide a valid email.'),
]], ]],
FormFields::repeated_password(), FormFields::repeated_password(),
@ -134,11 +135,11 @@ class Security extends Controller
// If we do find something, there's a duplicate // If we do find something, there's a duplicate
if ($user->getNickname() === $data['nickname']) { if ($user->getNickname() === $data['nickname']) {
// Register page feedback on nickname already in use // 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; throw new NicknameTakenException;
} else { } else {
// Register page feedback on email already in use // 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; throw new EmailTakenException;
} }
} }
@ -147,7 +148,7 @@ class Security extends Controller
try { try {
// This already checks if the nickname is being used // This already checks if the nickname is being used
$actor = GSActor::create(['nickname' => $valid_nickname]); $actor = Actor::create(['nickname' => $valid_nickname]);
$user = LocalUser::create([ $user = LocalUser::create([
'nickname' => $valid_nickname, 'nickname' => $valid_nickname,
'outgoing_email' => $data['email'], 'outgoing_email' => $data['email'],

View File

@ -32,38 +32,38 @@ class Subscribers extends Controller
/** /**
* Generic function that handles getting a representation for an actor from id * 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]); $actor = DB::findOneBy('actor', ['id' => $id]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* Generic function that handles getting a representation for an actor from nickname * 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]); $user = DB::findOneBy('local_user', ['nickname' => $nickname]);
$gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); $actor = DB::findOneBy('actor', ['id' => $user->getId()]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* Collection of an actor's subscribers * 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]);
} }
} }

View File

@ -32,38 +32,38 @@ class Subscriptions extends Controller
/** /**
* Generic function that handles getting a representation for an actor from id * 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]); $actor = DB::findOneBy('actor', ['id' => $id]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* Generic function that handles getting a representation for an actor from nickname * 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]); $user = DB::findOneBy('local_user', ['nickname' => $nickname]);
$gsactor = DB::findOneBy('gsactor', ['id' => $user->getId()]); $actor = DB::findOneBy('actor', ['id' => $user->getId()]);
if (empty($gsactor)) { if (empty($actor)) {
throw new ClientException(_m('No such actor.'), 404); throw new ClientException(_m('No such actor.'), 404);
} else { } else {
return $handle($gsactor); return $handle($actor);
} }
} }
/** /**
* Collection of an actor's subscriptions * 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]);
} }
} }

View File

@ -170,12 +170,12 @@ class UserPanel extends AbstractController
$label = str_replace('_', ' ', ucfirst($name)); $label = str_replace('_', ' ', ucfirst($name));
$labels = [ $labels = [
'target_gsactor_id' => 'Target Actors', 'target_actor_id' => 'Target Actors',
'dm' => 'DM', 'dm' => 'DM',
]; ];
$help = [ $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', 'activity_by_followed' => 'Notify me when someone I follow has new activity',
'mention' => 'Notify me when mentions me in a notice', 'mention' => 'Notify me when mentions me in a notice',
'reply' => 'Notify me when someone replies to a notice made by me', '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])]]; $form_defs['placeholder'][$name] = [$name, CheckboxType::class, ['data' => $val, 'label' => _m($labels[$name] ?? $label), 'help' => _m($help[$name])]];
break; break;
case Types::INTEGER: 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]; $form_defs['placeholder'][$name] = [$name, TextType::class, ['data' => $val, 'label' => _m($labels[$name]), 'help' => _m($help[$name])], 'transformer' => ActorArrayTransformer::class];
} }
break; break;

View File

@ -3,10 +3,10 @@
namespace App\DataFixtures; namespace App\DataFixtures;
use App\Core\VisibilityScope; use App\Core\VisibilityScope;
use App\Entity\Actor;
use App\Entity\Follow; use App\Entity\Follow;
use App\Entity\GroupInbox; use App\Entity\GroupInbox;
use App\Entity\GroupMember; use App\Entity\GroupMember;
use App\Entity\GSActor;
use App\Entity\LocalGroup; use App\Entity\LocalGroup;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Entity\Note; use App\Entity\Note;
@ -26,7 +26,7 @@ class CoreFixtures extends Fixture
'form_account_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('some password')]], 'form_account_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('some password')]],
'taken_group' => [LocalGroup::class, 'setGroupId', []], 'taken_group' => [LocalGroup::class, 'setGroupId', []],
] as $nick => [$entity, $method, $extra_create]) { ] as $nick => [$entity, $method, $extra_create]) {
$actor = GSActor::create(['nickname' => $nick]); $actor = Actor::create(['nickname' => $nick]);
$manager->persist($actor); $manager->persist($actor);
$ent = $entity::create(array_merge(['nickname' => $nick], $extra_create)); // cannot use array spread for arrays with string keys $ent = $entity::create(array_merge(['nickname' => $nick], $extra_create)); // cannot use array spread for arrays with string keys
$ent->{$method}($actor->getId()); $ent->{$method}($actor->getId());
@ -37,16 +37,16 @@ class CoreFixtures extends Fixture
$actors[$nick] = $actor; $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); $manager->persist($n);
$notes[] = Note::create(['gsactor_id' => $actors['taken_user']->getId(), 'content' => 'some other content', 'reply_to' => $n->getId()]); $notes[] = Note::create(['actor_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[] = Note::create(['actor_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[] = $group_note = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP]);
foreach ($notes as $note) { foreach ($notes as $note) {
$manager->persist($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->persist(GroupInbox::create(['group_id' => $local_entities['taken_group']->getGroupId(), 'activity_id' => $group_note->getId()]));
$manager->flush(); $manager->flush();
} }

View File

@ -40,7 +40,7 @@ class Activity extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $id; private int $id;
private int $gsactor_id; private int $actor_id;
private string $verb; private string $verb;
private string $object_type; private string $object_type;
private int $object_id; private int $object_id;
@ -59,15 +59,15 @@ class Activity extends Entity
return $this->id; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setVerb(string $verb): self public function setVerb(string $verb): self
@ -145,7 +145,7 @@ class Activity extends Entity
'name' => 'activity', 'name' => 'activity',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], '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'], '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_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'], 'object_id' => ['type' => 'int', 'not null' => true, 'description' => 'id in the referenced table'],

View File

@ -46,7 +46,7 @@ use Functional as F;
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActor extends Entity class Actor extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@ -224,21 +224,21 @@ class GSActor extends Entity
public static function getFromId(int $id): ?self public static function getFromId(int $id): ?self
{ {
return Cache::get('gsactor-id-' . $id, function () use ($id) { return Cache::get('actor-id-' . $id, function () use ($id) {
return DB::find('gsactor', ['id' => $id]); return DB::find('actor', ['id' => $id]);
}); });
} }
public static function getFromNickname(string $nickname): ?self public static function getFromNickname(string $nickname): ?self
{ {
return Cache::get('gsactor-nick-' . $nickname, function () use ($nickname) { return Cache::get('actor-nick-' . $nickname, function () use ($nickname) {
return DB::findOneBy('gsactor', ['nickname' => $nickname]); return DB::findOneBy('actor', ['nickname' => $nickname]);
}); });
} }
public static function getNicknameFromId(int $id): string 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(); return self::getFromId($id)->getNickname();
}); });
} }
@ -247,7 +247,7 @@ class GSActor extends Entity
{ {
return Cache::get('selftags-' . $this->id, return Cache::get('selftags-' . $this->id,
function () { 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); }, beta: $_test_force_recompute ? INF : 1.0);
} }
@ -258,7 +258,7 @@ class GSActor extends Entity
$tag_to_remove = array_diff($tag_existing, $tags); $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); }); $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) { 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); DB::persist($pt);
} }
foreach ($pt_to_remove as $pt) { foreach ($pt_to_remove as $pt) {
@ -305,9 +305,9 @@ class GSActor extends Entity
// Will throw exception on invalid input. // Will throw exception on invalid input.
$nickname = Nickname::normalize($nickname, check_already_used: false); $nickname = Nickname::normalize($nickname, check_already_used: false);
return Cache::get('relative-nickname-' . $nickname . '-' . $this->getId(), return Cache::get('relative-nickname-' . $nickname . '-' . $this->getId(),
fn () => DB::dql('select a from gsactor a where ' . fn () => DB::dql('select a from actor 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 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 gsactor a on f.follower = a.id where and f.followed = :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' . 'a.nickname = :nickname' .
'limit 1', 'limit 1',
['nickname' => $nickname, 'actor_id' => $this->getId()] ['nickname' => $nickname, 'actor_id' => $this->getId()]
@ -327,13 +327,13 @@ class GSActor extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
$def = [ $def = [
'name' => 'gsactor', 'name' => 'actor',
'description' => 'local and remote users, groups and bots are gsactors, for instance', 'description' => 'local and remote users, groups and bots are actors, for instance',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'], 'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'],
'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'], 'nickname' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username'],
'fullname' => ['type' => 'text', 'description' => 'display name'], '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'], 'homepage' => ['type' => 'text', 'description' => 'identifying URL'],
'bio' => ['type' => 'text', 'description' => 'descriptive biography'], 'bio' => ['type' => 'text', 'description' => 'descriptive biography'],
'location' => ['type' => 'text', 'description' => 'physical location'], 'location' => ['type' => 'text', 'description' => 'physical location'],
@ -346,10 +346,10 @@ class GSActor extends Entity
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'indexes' => [ 'indexes' => [
'gsactor_nickname_idx' => ['nickname'], 'actor_nickname_idx' => ['nickname'],
], ],
'fulltext indexes' => [ 'fulltext indexes' => [
'gsactor_fulltext_idx' => ['nickname', 'fullname', 'location', 'bio', 'homepage'], 'actor_fulltext_idx' => ['nickname', 'fullname', 'location', 'bio', 'homepage'],
], ],
]; ];

View File

@ -23,7 +23,7 @@ use App\Core\Entity;
use DateTimeInterface; use DateTimeInterface;
/** /**
* Entity for User's GSActor Block * Entity for User's Actor Block
* *
* @category DB * @category DB
* @package GNUsocial * @package GNUsocial
@ -36,7 +36,7 @@ use DateTimeInterface;
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActorBlock extends Entity class ActorBlock extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@ -83,10 +83,10 @@ class GSActorBlock extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
return [ return [
'name' => 'gsactor_block', 'name' => 'actor_block',
'fields' => [ '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'], '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' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'gsactor_block_blocked_fkey', 'not null' => true, 'description' => 'gsactor that is blocked'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['blocker', 'blocked'], 'primary key' => ['blocker', 'blocked'],

View File

@ -23,7 +23,7 @@ use App\Core\Entity;
use DateTimeInterface; use DateTimeInterface;
/** /**
* Entity for List of gsactors * Entity for List of actors
* *
* @category DB * @category DB
* @package GNUsocial * @package GNUsocial
@ -36,7 +36,7 @@ use DateTimeInterface;
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActorCircle extends Entity class ActorCircle extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@ -119,11 +119,11 @@ class GSActorCircle extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
return [ return [
'name' => 'gsactor_circle', 'name' => 'actor_circle',
'description' => 'a gsactor can have lists of gsactors, to separate their timeline', 'description' => 'a actor can have lists of actors, to separate their timeline',
'fields' => [ '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'], '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' => '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 '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'], 'description' => ['type' => 'text', 'description' => 'description of the people tag'],
'private' => ['type' => 'bool', 'default' => false, 'description' => 'is this tag private'], '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'], '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'], 'primary key' => ['tagger', 'tag'],
'indexes' => [ 'indexes' => [
'gsactor_list_modified_idx' => ['modified'], 'actor_list_modified_idx' => ['modified'],
'gsactor_list_tag_idx' => ['tag'], 'actor_list_tag_idx' => ['tag'],
'gsactor_list_tagger_tag_idx' => ['tagger', 'tag'], 'actor_list_tagger_tag_idx' => ['tagger', 'tag'],
], ],
]; ];
} }

View File

@ -23,7 +23,7 @@ use App\Core\Entity;
use DateTimeInterface; use DateTimeInterface;
/** /**
* Entity for GSActor Tag * Entity for Actor Tag
* *
* @category DB * @category DB
* @package GNUsocial * @package GNUsocial
@ -36,7 +36,7 @@ use DateTimeInterface;
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActorTag extends Entity class ActorTag extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
@ -95,18 +95,18 @@ class GSActorTag extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
return [ return [
'name' => 'gsactor_tag', 'name' => 'actor_tag',
'fields' => [ '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'], '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' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'gsactor_tag_tagged_fkey', 'not null' => true, 'description' => 'gsactor tagged'], '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'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],
'primary key' => ['tagger', 'tagged', 'tag'], 'primary key' => ['tagger', 'tagged', 'tag'],
'indexes' => [ 'indexes' => [
'gsactor_tag_modified_idx' => ['modified'], 'actor_tag_modified_idx' => ['modified'],
'gsactor_tag_tagger_tag_idx' => ['tagger', 'tag'], // For Circles 'actor_tag_tagger_tag_idx' => ['tagger', 'tag'], // For Circles
'gsactor_tag_tagged_idx' => ['tagged'], 'actor_tag_tagged_idx' => ['tagged'],
], ],
]; ];
} }

View File

@ -23,7 +23,7 @@ use App\Core\Entity;
use DateTimeInterface; use DateTimeInterface;
/** /**
* Entity for Gsactor Tag Subscription * Entity for actor Tag Subscription
* *
* @category DB * @category DB
* @package GNUsocial * @package GNUsocial
@ -36,35 +36,35 @@ use DateTimeInterface;
* @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActorTagFollow extends Entity class ActorTagFollow extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $gsactor_id; private int $actor_id;
private int $gsactor_tag; private int $actor_tag;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; 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; 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; return $this;
} }
public function getGSActorTag(): int public function getActorTag(): int
{ {
return $this->gsactor_tag; return $this->actor_tag;
} }
public function setCreated(DateTimeInterface $created): self public function setCreated(DateTimeInterface $created): self
@ -95,18 +95,18 @@ class GSActorTagFollow extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
return [ return [
'name' => 'gsactor_tag_follow', 'name' => 'actor_tag_follow',
'fields' => [ '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'], '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'],
'gsactor_tag' => ['type' => 'int', // 'foreign key' => true, 'target' => 'GSActorTag.tag', 'multiplicity' => 'one to one', // tag can't unique, but doctrine doesn't understand this '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' => 'gsactor_tag_follow_gsactor_tag_fkey', 'not null' => true, 'description' => 'foreign key to gsactor_tag', ], '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'], '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'], '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' => [ 'indexes' => [
'gsactor_tag_follow_gsactor_id_idx' => ['gsactor_id'], 'actor_tag_follow_actor_id_idx' => ['actor_id'],
'gsactor_tag_follow_created_idx' => ['created'], 'actor_tag_follow_created_idx' => ['created'],
], ],
]; ];
} }

View File

@ -32,12 +32,12 @@ use DateTimeInterface;
* @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class GSActorToAttachment extends Entity class ActorToAttachment extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $attachment_id; private int $attachment_id;
private int $gsactor_id; private int $actor_id;
private \DateTimeInterface $modified; private \DateTimeInterface $modified;
public function setAttachmentId(int $attachment_id): self public function setAttachmentId(int $attachment_id): self
@ -51,15 +51,15 @@ class GSActorToAttachment extends Entity
return $this->attachment_id; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setModified(DateTimeInterface $modified): self public function setModified(DateTimeInterface $modified): self
@ -79,16 +79,16 @@ class GSActorToAttachment extends Entity
public static function schemaDef(): array public static function schemaDef(): array
{ {
return [ return [
'name' => 'gsactor_to_attachment', 'name' => 'actor_to_attachment',
'fields' => [ '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'], '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'], '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' => [ 'indexes' => [
'attachment_id_idx' => ['attachment_id'], 'attachment_id_idx' => ['attachment_id'],
'gsactor_id_idx' => ['gsactor_id'], 'actor_id_idx' => ['actor_id'],
], ],
]; ];
} }

View File

@ -97,8 +97,8 @@ class Follow extends Entity
return [ return [
'name' => 'follow', 'name' => 'follow',
'fields' => [ 'fields' => [
'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'follow_follower_fkey', 'not null' => true, 'description' => 'gsactor listening'], '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' => 'GSActor.id', 'multiplicity' => 'one to one', 'name' => 'follow_followed_fkey', 'not null' => true, 'description' => 'gsactor being listened to'], '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'], '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'], 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
], ],

View File

@ -86,8 +86,8 @@ class FollowQueue extends Entity
'name' => 'follow_queue', 'name' => 'follow_queue',
'description' => 'Holder for Follow requests awaiting moderation.', 'description' => 'Holder for Follow requests awaiting moderation.',
'fields' => [ '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'], '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' => 'GSActor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_followed_fkey', 'not null' => true, 'description' => 'gsactor being followed'], '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'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
], ],
'primary key' => ['follower', 'followed'], 'primary key' => ['follower', 'followed'],

View File

@ -47,7 +47,7 @@ class Group extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $id; private int $id;
private int $gsactor_id; private int $actor_id;
private ?string $nickname; private ?string $nickname;
private ?string $fullname; private ?string $fullname;
private ?string $homepage; private ?string $homepage;
@ -76,15 +76,15 @@ class Group extends Entity
return $this->id; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setNickname(?string $nickname): self public function setNickname(?string $nickname): self
@ -266,12 +266,12 @@ class Group extends Entity
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} 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); $nickname = Nickname::normalize($nickname, check_already_used: false);
$group = null; $group = null;
@ -295,7 +295,7 @@ class Group extends Entity
'name' => '`group`', 'name' => '`group`',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], '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'], 'nickname' => ['type' => 'varchar', 'length' => 64, 'description' => 'nickname for addressing'],
'fullname' => ['type' => 'varchar', 'length' => 191, 'description' => 'display name'], 'fullname' => ['type' => 'varchar', 'length' => 191, 'description' => 'display name'],
'homepage' => ['type' => 'varchar', 'length' => 191, 'description' => 'URL, cached so we dont regenerate'], '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'], 'is_local' => ['type' => 'bool', 'description' => 'whether this group was created in this instance'],
'location' => ['type' => 'varchar', 'length' => 191, 'description' => 'related physical location, if any'], 'location' => ['type' => 'varchar', 'length' => 191, 'description' => 'related physical location, if any'],
'original_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'original size logo'], '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'], 'stream_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'stream-sized logo'],
'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'], 'mini_logo' => ['type' => 'varchar', 'length' => 191, 'description' => 'mini logo'],
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
@ -315,12 +315,12 @@ class Group extends Entity
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'unique keys' => [ 'unique keys' => [
'user_group_uri_key' => ['uri'], 'user_group_uri_key' => ['uri'],
'user_gsactor_id_key' => ['gsactor_id'], 'user_actor_id_key' => ['actor_id'],
], ],
'indexes' => [ 'indexes' => [
'user_group_nickname_idx' => ['nickname'], 'user_group_nickname_idx' => ['nickname'],
'user_group_gsactor_id_idx' => ['gsactor_id'], 'user_group_actor_id_idx' => ['actor_id'],
], ],
]; ];
} }

View File

@ -41,7 +41,7 @@ class GroupBlock extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $group_id; private int $group_id;
private int $blocked_gsactor; private int $blocked_actor;
private int $blocker_user; private int $blocker_user;
private \DateTimeInterface $modified; private \DateTimeInterface $modified;
@ -56,15 +56,15 @@ class GroupBlock extends Entity
return $this->group_id; 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; 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 public function setBlockerUser(int $blocker_user): self
@ -97,12 +97,12 @@ class GroupBlock extends Entity
return [ return [
'name' => 'group_block', 'name' => 'group_block',
'fields' => [ 'fields' => [
'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'group gsactor is blocked from'], 'group_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Group.id', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'group actor 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'], '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'], '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'], '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'],
]; ];
} }
} }

View File

@ -39,18 +39,18 @@ class GroupJoinQueue extends Entity
{ {
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $gsactor_id; private int $actor_id;
private int $group_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; 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 public function setGroupId(int $group_id): self
@ -73,13 +73,13 @@ class GroupJoinQueue extends Entity
'name' => 'group_join_queue', 'name' => 'group_join_queue',
'description' => 'Holder for group join requests awaiting moderation.', 'description' => 'Holder for group join requests awaiting moderation.',
'fields' => [ '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'], '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'], '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' => [ 'indexes' => [
'group_join_queue_gsactor_id_idx' => ['gsactor_id'], 'group_join_queue_actor_id_idx' => ['actor_id'],
'group_join_queue_group_id_idx' => ['group_id'], 'group_join_queue_group_id_idx' => ['group_id'],
], ],
]; ];
} }

View File

@ -41,7 +41,7 @@ class GroupMember extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $group_id; private int $group_id;
private int $gsactor_id; private int $actor_id;
private ?bool $is_admin; private ?bool $is_admin;
private ?string $uri; private ?string $uri;
private \DateTimeInterface $created; private \DateTimeInterface $created;
@ -58,15 +58,15 @@ class GroupMember extends Entity
return $this->group_id; 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; 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 public function setIsAdmin(?bool $is_admin): self
@ -121,22 +121,22 @@ class GroupMember extends Entity
return [ return [
'name' => 'group_member', 'name' => 'group_member',
'fields' => [ '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'], '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'], '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?'], 'is_admin' => ['type' => 'bool', 'default' => false, 'description' => 'is this actor an admin?'],
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'], 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], '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'], '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' => [ 'unique keys' => [
'group_member_uri_key' => ['uri'], 'group_member_uri_key' => ['uri'],
], ],
'indexes' => [ 'indexes' => [
'group_member_gsactor_id_idx' => ['gsactor_id'], 'group_member_actor_id_idx' => ['actor_id'],
'group_member_created_idx' => ['created'], 'group_member_created_idx' => ['created'],
'group_member_gsactor_id_created_idx' => ['gsactor_id', 'created'], 'group_member_actor_id_created_idx' => ['actor_id', 'created'],
'group_member_group_id_created_idx' => ['group_id', 'created'], 'group_member_group_id_created_idx' => ['group_id', 'created'],
], ],
]; ];
} }

View File

@ -187,7 +187,7 @@ class Link extends Entity
], ],
'primary key' => ['id'], 'primary key' => ['id'],
'indexes' => [ 'indexes' => [
'gsactor_url_hash_idx' => ['url_hash'], 'actor_url_hash_idx' => ['url_hash'],
], ],
]; ];
} }

View File

@ -96,7 +96,7 @@ class LocalGroup extends Entity
public function getActor() public function getActor()
{ {
return DB::find('gsactor', ['id' => $this->group_id]); return DB::find('actor', ['id' => $this->group_id]);
} }
public static function schemaDef(): array public static function schemaDef(): array

View File

@ -259,7 +259,7 @@ class LocalUser extends Entity implements UserInterface
public function getActor() 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', 'name' => 'local_user',
'description' => 'local users, bots, etc', 'description' => 'local users, bots, etc',
'fields' => [ 'fields' => [
'id' => ['type' => 'int', 'foreign key' => true, 'target' => 'GSActor.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to gsactor table'], '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 gsactor'], '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'], '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.'], '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'], 'incoming_email' => ['type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'],

View File

@ -44,7 +44,7 @@ class Note extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $id; private int $id;
private int $gsactor_id; private int $actor_id;
private string $content_type = 'text/plain'; private string $content_type = 'text/plain';
private string $content; private string $content;
private string $rendered; private string $rendered;
@ -68,15 +68,15 @@ class Note extends Entity
return $this->id; 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; 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 * @param string $content_type
*
* @return Note
*/ */
public function setContentType(string $content_type): self public function setContentType(string $content_type): self
{ {
@ -209,20 +211,20 @@ class Note extends Entity
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
// }}} Autocode // }}} 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 public function getActorNickname(): string
{ {
return GSActor::getNicknameFromId($this->gsactor_id); return Actor::getNicknameFromId($this->actor_id);
} }
public function getAvatarUrl() public function getAvatarUrl()
{ {
$url = null; $url = null;
Event::handle('GetAvatarUrl', [$this->getGSActorId(), &$url]); Event::handle('GetAvatarUrl', [$this->getActorId(), &$url]);
return $url; return $url;
} }
@ -272,7 +274,7 @@ class Note extends Entity
if (!empty($this->reply_to)) { if (!empty($this->reply_to)) {
return Cache::get('note-reply-to-' . $this->id, function () { return Cache::get('note-reply-to-' . $this->id, function () {
return DB::dql('select g from App\Entity\Note n join ' . 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(); ['reply' => $this->reply_to])[0]->getNickname();
}); });
} }
@ -282,18 +284,18 @@ class Note extends Entity
/** /**
* Whether this note is visible to the given actor * 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); $scope = VisibilityScope::create($this->scope);
return $scope->public return $scope->public
|| ($scope->follower || ($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 || ($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 ' . || ($scope->group && [] != DB::dql('select m from group_member m ' .
'join group_inbox i with m.group_id = i.group_id ' . 'join group_inbox i with m.group_id = i.group_id ' .
'join note n with i.activity_id = n.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()])); ['note_id' => $this->id, 'actor_id' => $a->getId()]));
} }
@ -312,7 +314,7 @@ class Note extends Entity
$processed_attachments = []; $processed_attachments = [];
foreach ($attachments as $f) { 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()]; $processed_attachments[] = [GSFile::sanitizeAndStoreFileAsAttachment($f), $f->getClientOriginalName()];
} }
@ -321,8 +323,8 @@ class Note extends Entity
if ($processed_attachments != []) { if ($processed_attachments != []) {
foreach ($processed_attachments as [$a, $fname]) { foreach ($processed_attachments as [$a, $fname]) {
if (DB::count('gsactor_to_attachment', $args = ['attachment_id' => $a->getId(), 'gsactor_id' => $args['gsactor_id']]) === 0) { if (DB::count('actor_to_attachment', $args = ['attachment_id' => $a->getId(), 'actor_id' => $args['actor_id']]) === 0) {
DB::persist(GSActorToAttachment::create($args)); DB::persist(ActorToAttachment::create($args));
} }
DB::persist(AttachmentToNote::create(['attachment_id' => $a->getId(), 'note_id' => $note->getId(), 'title' => $fname])); 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 public function getAttentionProfiles(): array
{ {
@ -346,7 +348,7 @@ class Note extends Entity
'name' => 'note', 'name' => 'note',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], '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' => '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'], '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)'], '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'], 'primary key' => ['id'],
'indexes' => [ 'indexes' => [
'note_created_id_is_local_idx' => ['created', 'is_local'], 'note_created_id_is_local_idx' => ['created', 'is_local'],
'note_gsactor_created_idx' => ['gsactor_id', 'created'], 'note_actor_created_idx' => ['actor_id', 'created'],
'note_is_local_created_gsactor_idx' => ['is_local', 'created', 'gsactor_id'], 'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'],
'note_repeat_of_created_idx' => ['repeat_of', 'created'], 'note_repeat_of_created_idx' => ['repeat_of', 'created'],
'note_conversation_created_idx' => ['conversation', 'created'], 'note_conversation_created_idx' => ['conversation', 'created'],
'note_reply_to_idx' => ['reply_to'], 'note_reply_to_idx' => ['reply_to'],
], ],
'fulltext indexes' => ['notice_fulltext_idx' => ['content']], 'fulltext indexes' => ['notice_fulltext_idx' => ['content']],
]; ];

View File

@ -41,7 +41,7 @@ class Notification extends Entity
// {{{ Autocode // {{{ Autocode
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $activity_id; private int $activity_id;
private int $gsactor_id; private int $actor_id;
private ?string $reason; private ?string $reason;
private \DateTimeInterface $created; private \DateTimeInterface $created;
private \DateTimeInterface $modified; private \DateTimeInterface $modified;
@ -57,15 +57,15 @@ class Notification extends Entity
return $this->activity_id; 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; return $this;
} }
public function getGSActorId(): int public function getActorId(): int
{ {
return $this->gsactor_id; return $this->actor_id;
} }
public function setReason(?string $reason): self public function setReason(?string $reason): self
@ -108,18 +108,18 @@ class Notification extends Entity
{ {
return [ return [
'name' => 'notification', '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' => [ 'fields' => [
'activity_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Activity.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'activity_id to give attention'], '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'], '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 gsactor_id'], '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'], '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'], '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' => [ 'indexes' => [
'attention_activity_id_idx' => ['activity_id'], 'attention_activity_id_idx' => ['activity_id'],
'attention_gsactor_id_idx' => ['gsactor_id'], 'attention_actor_id_idx' => ['actor_id'],
], ],
]; ];
} }

View File

@ -38,7 +38,7 @@ class UserNotificationPrefs extends Entity
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
private int $user_id; private int $user_id;
private string $transport; private string $transport;
private ?int $target_gsactor_id; private ?int $target_actor_id;
private bool $activity_by_followed = true; private bool $activity_by_followed = true;
private bool $mention = true; private bool $mention = true;
private bool $reply = true; private bool $reply = true;
@ -73,15 +73,15 @@ class UserNotificationPrefs extends Entity
return $this->transport; 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; 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 public function setActivityByFollowed(bool $activity_by_followed): self
@ -215,7 +215,7 @@ class UserNotificationPrefs extends Entity
'fields' => [ 'fields' => [
'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true], '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)'], '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'], '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'], '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'], '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'], 'primary key' => ['user_id', 'transport'],
'indexes' => [ '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'],
], ],
]; ];
} }

View File

@ -37,13 +37,13 @@ use App\Controller as C;
use App\Core\Router\RouteLoader; use App\Core\Router\RouteLoader;
use App\Util\Nickname; use App\Util\Nickname;
abstract class GSActor abstract class Actor
{ {
const LOAD_ORDER = 30; const LOAD_ORDER = 30;
public static function load(RouteLoader $r): void 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_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\GSActor::class, 'GSActorShowNickname'], options: ['is_system_path' => false]); $r->connect(id: 'actor_view_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}', target: [C\Actor::class, 'ActorShowNickname'], options: ['is_system_path' => false]);
} }
} }

View File

@ -20,7 +20,7 @@
// }}} // }}}
/** /**
* Define social's GSActor's subscribers routes * Define social's Actor's subscribers routes
* *
* @package GNUsocial * @package GNUsocial
* @category Router * @category Router

View File

@ -20,7 +20,7 @@
// }}} // }}}
/** /**
* Define social's GSActor's subscriptions routes * Define social's Actor's subscriptions routes
* *
* @package GNUsocial * @package GNUsocial
* @category Router * @category Router

View File

@ -34,7 +34,7 @@ namespace App\Util;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Core\Security; use App\Core\Security;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Exception\NoLoggedInUser; use App\Util\Exception\NoLoggedInUser;
use Functional as F; use Functional as F;
@ -111,7 +111,7 @@ abstract class Common
return Security::getUser(); return Security::getUser();
} }
public static function actor(): ?GSActor public static function actor(): ?Actor
{ {
return self::user()->getActor(); return self::user()->getActor();
} }

View File

@ -33,13 +33,13 @@
namespace App\Util\Exception; namespace App\Util\Exception;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Entity\GSActor; use App\Entity\Actor;
class EmailTakenException extends EmailException 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; $this->profile = $profile;
parent::__construct($msg, $code); parent::__construct($msg, $code);

View File

@ -42,13 +42,13 @@
namespace App\Util\Exception; namespace App\Util\Exception;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Entity\GSActor; use App\Entity\Actor;
class NicknameTakenException extends NicknameException 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; $this->profile = $profile;
parent::__construct($msg, $code); parent::__construct($msg, $code);

View File

@ -32,12 +32,12 @@
namespace App\Util\Form; namespace App\Util\Form;
use App\Entity\GSActor; use App\Entity\Actor;
class ActorArrayTransformer extends ArrayTransformer class ActorArrayTransformer extends ArrayTransformer
{ {
/** /**
* Transforms array of GSActors into string of usernames * Transforms array of Actors into string of nicknames
* *
* @param array $a * @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 * @param string $s
* *
@ -61,7 +61,7 @@ class ActorArrayTransformer extends ArrayTransformer
public function reverseTransform($s) public function reverseTransform($s)
{ {
return array_map( return array_map(
function ($nickmame) { return GSActor::getFromNickname($nickmame); }, function ($nickmame) { return Actor::getFromNickname($nickmame); },
parent::reverseTransform($s) parent::reverseTransform($s)
); );
} }

View File

@ -33,8 +33,8 @@ namespace App\Util;
use App\Core\Event; use App\Core\Event;
use App\Core\Log; use App\Core\Log;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Actor;
use App\Entity\Group; use App\Entity\Group;
use App\Entity\GSActor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Exception\NicknameException; use App\Util\Exception\NicknameException;
use App\Util\Exception\ServerException; 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 * 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(). * such. Should not be used directly; rather, call common_linkify_mentions().
* *
* @param string $text * @param string $text
* @param GSActor $actor the GSActor that is sending the current 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 * @param Note $parent the Note this text is in reply to, if any
* *
* @return array * @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 = []; $mentions = [];
if (Event::handle('StartFindMentions', [$actor, $text, &$mentions])) { if (Event::handle('StartFindMentions', [$actor, $text, &$mentions])) {
@ -583,7 +583,7 @@ abstract class Formatting
$mentioned = $actor->findRelativeActor($nickname); $mentioned = $actor->findRelativeActor($nickname);
} }
if ($mentioned instanceof GSActor) { if ($mentioned instanceof Actor) {
$url = $mentioned->getUri(); // prefer the URI as URL, if it is one. $url = $mentioned->getUri(); // prefer the URI as URL, if it is one.
if (!Common::isValidHttpUrl($url)) { if (!Common::isValidHttpUrl($url)) {
$url = $mentioned->getUrl(); $url = $mentioned->getUrl();
@ -697,13 +697,13 @@ abstract class Formatting
* *
* Should generally not be called except from common_render_content(). * Should generally not be called except from common_render_content().
* *
* @param string $text partially-rendered HTML * @param string $text partially-rendered HTML
* @param GSActor $author the GSActor that is composing the current notice * @param Actor $author the Actor that is composing the current notice
* @param Note $parent the Note this is sent in reply to, if any * @param Note $parent the Note this is sent in reply to, if any
* *
* @return string partially-rendered HTML * @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); $mentions = self::findMentions($text, $author, $parent);

View File

@ -30,7 +30,7 @@
namespace App\Util\Notification; namespace App\Util\Notification;
use App\Entity\GSActor; use App\Entity\Actor;
class Notification class Notification
{ {
@ -50,11 +50,11 @@ class Notification
/** /**
* Who caused this 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->type = $type;
$this->gsactor = $gsactor; $this->actor = $actor;
} }
} }

View File

@ -1,10 +1,10 @@
{% extends 'stdgrid.html.twig' %} {% extends 'stdgrid.html.twig' %}
{% set id = gsactor.id %} {% set id = actor.id %}
{% set nick = gsactor.nickname %} {% set nick = actor.nickname %}
{# TODO: how to get avatar in here? Tags and rest of profile info? #} {# 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 %} {% block title %}{{ nick }}'s profile{% endblock %}

View File

@ -20,7 +20,7 @@
namespace App\Tests\Core\DB; namespace App\Tests\Core\DB;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\NotFoundException; use App\Util\Exception\NotFoundException;
@ -34,51 +34,51 @@ class DBTest extends GNUsocialTestCase
public function testDql() public function testDql()
{ {
static::bootKernel(); 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(is_array($actor));
static::assertTrue($actor[0] instanceof GSActor); static::assertTrue($actor[0] instanceof Actor);
} }
public function testSql() public function testSql()
{ {
static::bootKernel(); 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(is_array($actor));
static::assertTrue($actor[0] instanceof GSActor); static::assertTrue($actor[0] instanceof Actor);
} }
public function testFindBy() public function testFindBy()
{ {
static::bootKernel(); static::bootKernel();
$actor = DB::findBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findBy('actor', ['nickname' => 'taken_user']);
static::assertTrue(is_array($actor)); 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(is_array($actor));
static::assertTrue($actor[0] instanceof GSActor); static::assertTrue($actor[0] instanceof Actor);
} }
public function testFindOneBy() public function testFindOneBy()
{ {
static::bootKernel(); static::bootKernel();
$actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
static::assertTrue($actor instanceof GSActor); static::assertTrue($actor instanceof Actor);
static::assertThrows(DuplicateFoundException::class, fn () => DB::findOneBy('gsactor', ['is_null' => 'bio'])); static::assertThrows(DuplicateFoundException::class, fn () => DB::findOneBy('actor', ['is_null' => 'bio']));
static::assertThrows(NotFoundException::class, fn () => DB::findOneBy('gsactor', ['nickname' => 'nickname_not_in_use'])); static::assertThrows(NotFoundException::class, fn () => DB::findOneBy('actor', ['nickname' => 'nickname_not_in_use']));
} }
public function testCount() public function testCount()
{ {
static::bootKernel(); static::bootKernel();
static::assertTrue(DB::count('gsactor', ['nickname' => 'taken_user']) == 1); static::assertTrue(DB::count('actor', ['nickname' => 'taken_user']) == 1);
static::assertTrue(DB::count('gsactor', []) != 1); static::assertTrue(DB::count('actor', []) != 1);
} }
public function testPersistWithSameId() public function testPersistWithSameId()
{ {
$actor = GSActor::create(['nickname' => 'test', 'normalized_nickname' => 'test']); $actor = Actor::create(['nickname' => 'test', 'normalized_nickname' => 'test']);
$user = LocalUser::create(['nickname' => 'test']); $user = LocalUser::create(['nickname' => 'test']);
$id = DB::persistWithSameId($actor, $user, fn ($id) => $id); $id = DB::persistWithSameId($actor, $user, fn ($id) => $id);
static::assertTrue($id != 0); static::assertTrue($id != 0);

View File

@ -31,7 +31,7 @@ class UpdateListenerTest extends GNUsocialTestCase
public function testPreUpdateExists() public function testPreUpdateExists()
{ {
static::bootKernel(); static::bootKernel();
$actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
$date = new DateTime('1999-09-23'); $date = new DateTime('1999-09-23');
$actor->setModified($date); $actor->setModified($date);
static::assertSame($actor->getModified(), $date); static::assertSame($actor->getModified(), $date);

View File

@ -23,7 +23,7 @@ namespace App\Tests\Core;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Form; use App\Core\Form;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use App\Util\Form\ArrayTransformer; use App\Util\Form\ArrayTransformer;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
@ -93,7 +93,7 @@ class FormTest extends GNUsocialTestCase
public function testCreateUpdateObject() public function testCreateUpdateObject()
{ {
$nick = 'form_testing_new_user'; $nick = 'form_testing_new_user';
$user = GSActor::create(['nickname' => $nick, 'normalized_nickname' => $nick]); $user = Actor::create(['nickname' => $nick, 'normalized_nickname' => $nick]);
$form = Form::create([ $form = Form::create([
['nickname', TextareaType::class, []], ['nickname', TextareaType::class, []],
['normalized_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); $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); 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); 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); $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); static::assertSame($mock_form, $ret);

View File

@ -20,34 +20,34 @@
namespace App\Tests\Entity; namespace App\Tests\Entity;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Entity\GSActorTag; use App\Entity\ActorTag;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use Functional as F; use Functional as F;
use Jchook\AssertThrows\AssertThrows; use Jchook\AssertThrows\AssertThrows;
class GSActorTest extends GNUsocialTestCase class ActorTest extends GNUsocialTestCase
{ {
use AssertThrows; use AssertThrows;
public function testGetAvatarUrl() public function testGetAvatarUrl()
{ {
$actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
static::assertSame("/{$actor->getId()}/avatar", $actor->getAvatarUrl()); static::assertSame("/{$actor->getId()}/avatar", $actor->getAvatarUrl());
} }
public function testGetFromNickname() public function testGetFromNickname()
{ {
static::assertNotNull(GSActor::getFromNickname('taken_user')); static::assertNotNull(Actor::getFromNickname('taken_user'));
} }
public function testSelfTags() public function testSelfTags()
{ {
$actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
$tags = $actor->getSelfTags(); $tags = $actor->getSelfTags();
$actor->setSelfTags(['foo'], $tags); $actor->setSelfTags(['foo'], $tags);
DB::flush(); 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())); static::assertSame(['foo'], $get_tags($tags = $actor->getSelfTags()));
$actor->setSelfTags(['bar'], $tags); $actor->setSelfTags(['bar'], $tags);
DB::flush(); DB::flush();

View File

@ -102,8 +102,8 @@ class AttachmentTest extends GNUsocialTestCase
static::assertSame('Untitled attachment', $attachment->getBestTitle()); static::assertSame('Untitled attachment', $attachment->getBestTitle());
$attachment->setFilename($filename); $attachment->setFilename($filename);
$actor = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
DB::persist($note = Note::create(['gsactor_id' => $actor->getId(), 'content' => 'some content'])); 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::persist(AttachmentToNote::create(['attachment_id' => $attachment->getId(), 'note_id' => $note->getId(), 'title' => 'A title']));
DB::flush(); DB::flush();

View File

@ -30,7 +30,7 @@ class GroupTest extends GNUsocialTestCase
public function testGetActor() public function testGetActor()
{ {
$group = DB::findOneBy('local_group', ['nickname' => 'taken_group']); $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()); static::assertSame($actor, $group->getActor());
} }
} }

View File

@ -31,10 +31,10 @@ class NoteTest extends GNUsocialTestCase
public function testGetReplies() public function testGetReplies()
{ {
$user = DB::findOneBy('local_user', ['nickname' => 'taken_user']); $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(); $replies = $note->getReplies();
static::assertSame('some other content', $replies[0]->getContent()); 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($note->getId(), $replies[0]->getReplyTo());
static::assertSame($user->getNickname(), $replies[0]->getReplyToNickname()); static::assertSame($user->getNickname(), $replies[0]->getReplyToNickname());
@ -42,21 +42,21 @@ class NoteTest extends GNUsocialTestCase
public function testIsVisibleTo() public function testIsVisibleTo()
{ {
$actor1 = DB::findOneBy('gsactor', ['nickname' => 'taken_user']); $actor1 = DB::findOneBy('actor', ['nickname' => 'taken_user']);
$actor2 = DB::findOneBy('gsactor', ['nickname' => 'taken_group']); $actor2 = DB::findOneBy('actor', ['nickname' => 'taken_group']);
$actor3 = DB::findOneBy('gsactor', ['nickname' => 'some_user']); $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::assertTrue($note_visible_to_1->isVisibleTo($actor1));
static::assertFalse($note_visible_to_1->isVisibleTo($actor2)); static::assertFalse($note_visible_to_1->isVisibleTo($actor2));
static::assertFalse($note_visible_to_1->isVisibleTo($actor3)); 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($actor1));
static::assertTrue($note_public->isVisibleTo($actor2)); static::assertTrue($note_public->isVisibleTo($actor2));
static::assertTrue($note_public->isVisibleTo($actor3)); 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::assertTrue($group_note->isVisibleTo($actor3));
static::assertFalse($group_note->isVisibleTo($actor2)); static::assertFalse($group_note->isVisibleTo($actor2));
static::assertFalse($group_note->isVisibleTo($actor1)); static::assertFalse($group_note->isVisibleTo($actor1));

View File

@ -21,7 +21,7 @@ namespace App\Tests\Util;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Security; use App\Core\Security;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\NoLoggedInUser; use App\Util\Exception\NoLoggedInUser;
@ -86,11 +86,11 @@ class CommonTest extends GNUsocialTestCase
static::assertFalse(Common::isLoggedIn()); static::assertFalse(Common::isLoggedIn());
$metadata = $this->createMock(ClassMetadataInfo::class); $metadata = $this->createMock(ClassMetadataInfo::class);
$metadata->method('getTableName')->willReturn('gsactor'); $metadata->method('getTableName')->willReturn('actor');
$metadata->method('getMetadataValue')->willReturn('App\Entity\GSActor'); $metadata->method('getMetadataValue')->willReturn('App\Entity\Actor');
$factory = $this->createMock(ClassMetadataFactory::class); $factory = $this->createMock(ClassMetadataFactory::class);
$factory->method('getAllMetadata')->willReturn([$metadata]); $factory->method('getAllMetadata')->willReturn([$metadata]);
$actor = GSActor::create(['nickname' => 'nick']); $actor = Actor::create(['nickname' => 'nick']);
$actor->setId(0); $actor->setId(0);
$em = $this->createMock(EntityManager::class); $em = $this->createMock(EntityManager::class);
$em->method('find')->willReturn($actor); $em->method('find')->willReturn($actor);

View File

@ -19,7 +19,7 @@
namespace App\Tests\Util\Form; namespace App\Tests\Util\Form;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Util\Form\ActorArrayTransformer; use App\Util\Form\ActorArrayTransformer;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@ -29,9 +29,9 @@ class ActorArrayTransformerTest extends WebTestCase
{ {
static::assertSame('', (new ActorArrayTransformer)->transform([])); static::assertSame('', (new ActorArrayTransformer)->transform([]));
$user1 = GSActor::create(['nickname' => 'user1']); $user1 = Actor::create(['nickname' => 'user1']);
$user2 = GSActor::create(['nickname' => 'user2']); $user2 = Actor::create(['nickname' => 'user2']);
$user3 = GSActor::create(['nickname' => 'user3']); $user3 = Actor::create(['nickname' => 'user3']);
$testArr = [$user1, $user2, $user3]; $testArr = [$user1, $user2, $user3];

View File

@ -19,7 +19,7 @@
namespace App\Tests\Util\Notification; namespace App\Tests\Util\Notification;
use App\Entity\GSActor; use App\Entity\Actor;
use App\Util\Notification\Notification; use App\Util\Notification\Notification;
use Jchook\AssertThrows\AssertThrows; use Jchook\AssertThrows\AssertThrows;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -30,6 +30,6 @@ class NotificationTest extends TestCase
public function testNotificationBitmap() public function testNotificationBitmap()
{ {
static::assertTrue((new Notification(Notification::DM, new GSActor())) instanceof Notification); static::assertTrue((new Notification(Notification::DM, new Actor())) instanceof Notification);
} }
} }