2020-03-29 20:56:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// {{{ License
|
2020-06-30 17:26:40 +01:00
|
|
|
|
2020-05-20 17:53:53 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
2020-03-29 20:56:35 +01:00
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
2020-05-10 21:43:15 +01:00
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
2020-03-29 20:56:35 +01:00
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
2020-05-10 21:43:15 +01:00
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
2020-03-29 20:56:35 +01:00
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
2020-06-30 17:26:40 +01:00
|
|
|
|
2020-03-29 20:56:35 +01:00
|
|
|
// }}}
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
2020-05-10 21:43:15 +01:00
|
|
|
use DateTimeInterface;
|
|
|
|
|
2020-03-29 20:56:35 +01:00
|
|
|
/**
|
|
|
|
* Entity for notices
|
|
|
|
*
|
|
|
|
* @category DB
|
|
|
|
* @package GNUsocial
|
|
|
|
*
|
|
|
|
* @author Hugo Sales <hugo@fc.up.pt>
|
|
|
|
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
|
|
|
*/
|
2020-08-13 00:57:22 +01:00
|
|
|
class Note
|
2020-03-29 20:56:35 +01:00
|
|
|
{
|
2020-03-30 15:00:13 +01:00
|
|
|
// {{{ Autocode
|
2020-03-29 20:56:35 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
private int $id;
|
2020-08-13 02:35:01 +01:00
|
|
|
private int $gsactor_id;
|
2020-03-30 16:13:51 +01:00
|
|
|
private ?string $content;
|
|
|
|
private ?int $reply_to;
|
2020-06-30 19:20:50 +01:00
|
|
|
private ?bool $is_local;
|
2020-03-30 16:13:51 +01:00
|
|
|
private ?string $source;
|
|
|
|
private ?int $conversation;
|
|
|
|
private ?int $repeat_of;
|
|
|
|
private ?int $scope;
|
2020-08-13 02:35:01 +01:00
|
|
|
private DateTimeInterface $created;
|
|
|
|
private DateTimeInterface $modified;
|
2020-03-30 16:13:51 +01:00
|
|
|
|
|
|
|
public function setId(int $id): self
|
|
|
|
{
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getId(): int
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
2020-08-13 02:35:01 +01:00
|
|
|
public function setGsactorId(int $gsactor_id): self
|
2020-03-30 16:13:51 +01:00
|
|
|
{
|
2020-08-13 02:35:01 +01:00
|
|
|
$this->gsactor_id = $gsactor_id;
|
2020-03-30 16:13:51 +01:00
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-08-13 02:35:01 +01:00
|
|
|
public function getGsactorId(): int
|
2020-03-30 16:13:51 +01:00
|
|
|
{
|
2020-08-13 02:35:01 +01:00
|
|
|
return $this->gsactor_id;
|
2020-03-30 16:13:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setContent(?string $content): self
|
|
|
|
{
|
|
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getContent(): ?string
|
|
|
|
{
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setReplyTo(?int $reply_to): self
|
|
|
|
{
|
|
|
|
$this->reply_to = $reply_to;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getReplyTo(): ?int
|
|
|
|
{
|
|
|
|
return $this->reply_to;
|
|
|
|
}
|
|
|
|
|
2020-06-30 19:20:50 +01:00
|
|
|
public function setIsLocal(?bool $is_local): self
|
2020-03-30 16:13:51 +01:00
|
|
|
{
|
|
|
|
$this->is_local = $is_local;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-06-30 19:20:50 +01:00
|
|
|
public function getIsLocal(): ?bool
|
2020-03-30 16:13:51 +01:00
|
|
|
{
|
|
|
|
return $this->is_local;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSource(?string $source): self
|
|
|
|
{
|
|
|
|
$this->source = $source;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getSource(): ?string
|
|
|
|
{
|
|
|
|
return $this->source;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setConversation(?int $conversation): self
|
|
|
|
{
|
|
|
|
$this->conversation = $conversation;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getConversation(): ?int
|
|
|
|
{
|
|
|
|
return $this->conversation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRepeatOf(?int $repeat_of): self
|
|
|
|
{
|
|
|
|
$this->repeat_of = $repeat_of;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getRepeatOf(): ?int
|
|
|
|
{
|
|
|
|
return $this->repeat_of;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setScope(?int $scope): self
|
|
|
|
{
|
|
|
|
$this->scope = $scope;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-03-30 16:13:51 +01:00
|
|
|
public function getScope(): ?int
|
|
|
|
{
|
|
|
|
return $this->scope;
|
|
|
|
}
|
|
|
|
|
2020-06-30 19:20:50 +01:00
|
|
|
public function setCreated(DateTimeInterface $created): self
|
|
|
|
{
|
|
|
|
$this->created = $created;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-06-30 19:20:50 +01:00
|
|
|
public function getCreated(): DateTimeInterface
|
|
|
|
{
|
|
|
|
return $this->created;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setModified(DateTimeInterface $modified): self
|
|
|
|
{
|
|
|
|
$this->modified = $modified;
|
|
|
|
return $this;
|
|
|
|
}
|
2020-08-08 17:11:18 +01:00
|
|
|
|
2020-06-30 19:20:50 +01:00
|
|
|
public function getModified(): DateTimeInterface
|
|
|
|
{
|
|
|
|
return $this->modified;
|
|
|
|
}
|
|
|
|
|
2020-03-30 15:00:13 +01:00
|
|
|
// }}} Autocode
|
2020-03-29 20:56:35 +01:00
|
|
|
|
|
|
|
public static function schemaDef(): array
|
|
|
|
{
|
|
|
|
$def = [
|
2020-08-13 00:57:22 +01:00
|
|
|
'name' => 'note',
|
2020-03-29 20:56:35 +01:00
|
|
|
'fields' => [
|
2020-06-30 17:26:40 +01:00
|
|
|
'id' => ['type' => 'serial', 'not null' => true],
|
2020-08-13 00:57:22 +01:00
|
|
|
'gsactor_id' => ['type' => 'int', 'not null' => true, 'description' => 'who made the note'],
|
|
|
|
'content' => ['type' => 'text', 'description' => 'note content'],
|
|
|
|
'reply_to' => ['type' => 'int', 'description' => 'note replied to, null if root of a conversation'],
|
|
|
|
'is_local' => ['type' => 'bool', 'description' => 'was this note generated by a local actor'],
|
|
|
|
'source' => ['type' => 'varchar', 'length' => 32, 'description' => 'source of note, like "web", "im", or "clientname"'],
|
2020-06-30 17:26:40 +01:00
|
|
|
'conversation' => ['type' => 'int', 'description' => 'the local conversation id'],
|
2020-08-13 00:57:22 +01:00
|
|
|
'repeat_of' => ['type' => 'int', 'description' => 'note this is a repeat of'],
|
2020-06-30 17:26:40 +01:00
|
|
|
'scope' => ['type' => 'int', 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = followers; 16 = messages; null = default'],
|
|
|
|
'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'],
|
2020-03-29 20:56:35 +01:00
|
|
|
],
|
2020-08-13 00:57:22 +01:00
|
|
|
'primary key' => ['id'],
|
2020-03-29 20:56:35 +01:00
|
|
|
'foreign keys' => [
|
2020-08-13 00:57:22 +01:00
|
|
|
'note_gsactor_id_fkey' => ['gsactor', ['gsactor_id' => 'id']],
|
|
|
|
'note_reply_to_fkey' => ['note', ['reply_to' => 'id']],
|
|
|
|
'note_note_source_fkey' => ['note_source', ['source' => 'code']],
|
|
|
|
'note_conversation_fkey' => ['conversation', ['conversation' => 'id']],
|
|
|
|
'note_repeat_of_fkey' => ['note', ['repeat_of' => 'id']],
|
2020-03-29 20:56:35 +01:00
|
|
|
],
|
|
|
|
'indexes' => [
|
2020-08-13 00:57:22 +01:00
|
|
|
'note_created_id_is_local_idx' => ['created', 'is_local'],
|
|
|
|
'note_gsactor_created_idx' => ['gsactor_id', 'created'],
|
|
|
|
'note_is_local_created_gsactor_idx' => ['is_local', 'created', 'gsactor_id'],
|
|
|
|
'note_repeat_of_created_idx' => ['repeat_of', 'created'],
|
|
|
|
'note_conversation_created_idx' => ['conversation', 'created'],
|
|
|
|
'note_reply_to_idx' => ['reply_to'],
|
2020-03-29 20:56:35 +01:00
|
|
|
],
|
2020-08-13 00:57:22 +01:00
|
|
|
'fulltext indexes' => ['notice_fulltext_idx' => ['content']],
|
2020-03-29 20:56:35 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
return $def;
|
|
|
|
}
|
|
|
|
}
|