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