forked from GNUsocial/gnu-social
[PLUGIN][Favourite][Repeat] Add notification target getter
This commit is contained in:
parent
625618b4e0
commit
f5f7fc6056
@ -22,6 +22,8 @@ declare(strict_types = 1);
|
|||||||
namespace Plugin\Favourite\Entity;
|
namespace Plugin\Favourite\Entity;
|
||||||
|
|
||||||
use App\Core\Entity;
|
use App\Core\Entity;
|
||||||
|
use App\Entity\Note;
|
||||||
|
use App\Util\Formatting;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
class Favourite extends Entity
|
class Favourite extends Entity
|
||||||
@ -80,6 +82,24 @@ class Favourite extends Entity
|
|||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
// }}} Autocode
|
// }}} Autocode
|
||||||
|
|
||||||
|
public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null): array
|
||||||
|
{
|
||||||
|
if (!\array_key_exists('object', $ids_already_known)) {
|
||||||
|
$target_ids = Note::getById($this->getNoteId())->getNotificationTargetIds();
|
||||||
|
} else {
|
||||||
|
$target_ids = $ids_already_known['object'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Additional actors that should know about this
|
||||||
|
if (\array_key_exists('additional', $ids_already_known)) {
|
||||||
|
array_push($target_ids, ...$ids_already_known['additional']);
|
||||||
|
} else {
|
||||||
|
return $target_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($target_ids);
|
||||||
|
}
|
||||||
|
|
||||||
public static function schemaDef()
|
public static function schemaDef()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -90,6 +90,24 @@ class NoteRepeat extends Entity
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNotificationTargetIds(array $ids_already_known = [], ?int $sender_id = null): array
|
||||||
|
{
|
||||||
|
if (!\array_key_exists('object', $ids_already_known)) {
|
||||||
|
$target_ids = Note::getById($this->getNoteId())->getNotificationTargetIds();
|
||||||
|
} else {
|
||||||
|
$target_ids = $ids_already_known['object'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Additional actors that should know about this
|
||||||
|
if (\array_key_exists('additional', $ids_already_known)) {
|
||||||
|
array_push($target_ids, ...$ids_already_known['additional']);
|
||||||
|
} else {
|
||||||
|
return $target_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($target_ids);
|
||||||
|
}
|
||||||
|
|
||||||
public static function schemaDef(): array
|
public static function schemaDef(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -51,16 +51,16 @@ class Note extends Entity
|
|||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
private int $id;
|
private int $id;
|
||||||
private int $actor_id;
|
private int $actor_id;
|
||||||
private ?string $content;
|
private ?string $content = null;
|
||||||
private string $content_type = 'text/plain';
|
private string $content_type = 'text/plain';
|
||||||
private ?string $rendered;
|
private ?string $rendered;
|
||||||
private int $conversation_id;
|
private int $conversation_id;
|
||||||
private ?int $reply_to;
|
private ?int $reply_to = null;
|
||||||
private bool $is_local;
|
private bool $is_local;
|
||||||
private ?string $source;
|
private ?string $source;
|
||||||
private int $scope = VisibilityScope::PUBLIC;
|
private int $scope = VisibilityScope::PUBLIC;
|
||||||
private ?string $url;
|
private ?string $url;
|
||||||
private ?int $language_id;
|
private ?int $language_id = null;
|
||||||
private DateTimeInterface $created;
|
private DateTimeInterface $created;
|
||||||
private DateTimeInterface $modified;
|
private DateTimeInterface $modified;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user