[NOTE] Add mimetype to notes

This commit is contained in:
2021-09-09 03:46:30 +01:00
committed by Hugo Sales
parent c69b28d894
commit 7c465bba5f
3 changed files with 61 additions and 38 deletions

View File

@@ -38,20 +38,21 @@ 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 Note extends Entity implements \JsonSerializable
class Note extends Entity
{
// {{{ Autocode
// @codeCoverageIgnoreStart
private int $id;
private int $gsactor_id;
private ?string $content;
private ?string $rendered;
private string $content_type = 'text/plain';
private string $content;
private string $rendered;
private ?int $reply_to;
private ?bool $is_local;
private ?string $source;
private ?int $conversation;
private ?int $repeat_of;
private int $scope = 1;
private int $scope = VisibilityScope::PUBLIC;
private \DateTimeInterface $created;
private \DateTimeInterface $modified;
@@ -77,6 +78,23 @@ class Note extends Entity implements \JsonSerializable
return $this->gsactor_id;
}
/**
* @return string
*/
public function getContentType(): string
{
return $this->content_type;
}
/**
* @param string $content_type
*/
public function setContentType(string $content_type): self
{
$this->content_type = $content_type;
return $this;
}
public function setContent(?string $content): self
{
$this->content = $content;
@@ -272,14 +290,6 @@ class Note extends Entity implements \JsonSerializable
['note_id' => $this->id, 'actor_id' => $a->getId()]));
}
public function jsonSerialize()
{
return [
'content' => $this->getContent(),
'author' => $this->getGSActorId(),
];
}
public static function schemaDef(): array
{
return [
@@ -287,7 +297,8 @@ class Note extends Entity implements \JsonSerializable
'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'],
'content' => ['type' => 'text', 'description' => 'note content'],
'content' => ['type' => 'text', 'not null' => true, 'description' => 'note content'],
'content_type' => ['type' => 'varchar', 'not null' => true, 'default' => 'text/plain', 'length' => 129, 'description' => 'A note can be written in a multitude of formats such as text/plain, text/markdown, application/x-latex, and text/html'],
'rendered' => ['type' => 'text', 'description' => 'rendered note content, so we can keep the microtags (if not local)'],
'reply_to' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'description' => 'note replied to, null if root of a conversation'],
'is_local' => ['type' => 'bool', 'description' => 'was this note generated by a local actor'],