[CARDS][Note] In conversation time ago information added
This commit is contained in:
@@ -50,6 +50,7 @@ class Note extends Entity
|
||||
private ?string $content_type = null;
|
||||
private ?string $content = null;
|
||||
private ?string $rendered = null;
|
||||
private ?int $reply_to;
|
||||
private bool $is_local;
|
||||
private ?string $source;
|
||||
private int $scope = VisibilityScope::PUBLIC;
|
||||
@@ -113,6 +114,17 @@ class Note extends Entity
|
||||
return $this->rendered;
|
||||
}
|
||||
|
||||
public function setReplyTo(?int $reply_to): self
|
||||
{
|
||||
$this->reply_to = $reply_to;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReplyTo(): ?int
|
||||
{
|
||||
return $this->reply_to;
|
||||
}
|
||||
|
||||
public function setIsLocal(bool $is_local): self
|
||||
{
|
||||
$this->is_local = $is_local;
|
||||
@@ -300,6 +312,16 @@ class Note extends Entity
|
||||
});
|
||||
}
|
||||
|
||||
public function getReplyToNote(): ?Note
|
||||
{
|
||||
return self::getWithPK($this->getReplyTo());
|
||||
}
|
||||
|
||||
public function getReplies(): array
|
||||
{
|
||||
return Cache::getList('note-replies-' . $this->id, fn () => DB::dql('select n from note n where n.reply_to = :id', ['id' => $this->id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this note is visible to the given actor
|
||||
*/
|
||||
@@ -347,6 +369,7 @@ class Note extends Entity
|
||||
'content' => ['type' => 'text', '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', 'not null' => true, 'description' => 'was this note generated by a local actor'],
|
||||
'source' => ['type' => 'varchar', 'foreign key' => true, 'length' => 32, 'target' => 'NoteSource.code', 'multiplicity' => 'many to one', 'description' => 'fkey to source of note, like "web", "im", or "clientname"'],
|
||||
'scope' => ['type' => 'int', 'not null' => true, 'default' => VisibilityScope::PUBLIC, 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = subscribers; 16 = messages; null = default'],
|
||||
@@ -360,6 +383,7 @@ class Note extends Entity
|
||||
'note_created_id_is_local_idx' => ['created', 'is_local'],
|
||||
'note_actor_created_idx' => ['actor_id', 'created'],
|
||||
'note_is_local_created_actor_idx' => ['is_local', 'created', 'actor_id'],
|
||||
'note_reply_to_idx' => ['reply_to'],
|
||||
],
|
||||
'fulltext indexes' => ['notice_fulltext_idx' => ['content']], // TODO make this configurable
|
||||
];
|
||||
|
Reference in New Issue
Block a user