gnu-social/plugins/WebHooks/Entity/WebHook.php

113 lines
3.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// 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.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace Plugin\WebHooks\Entity;
use App\Core\Entity;
use DateTimeInterface;
class WebHook extends Entity
{
// {{{ Autocode
// @codeCoverageIgnoreStart
private int $actor_id;
private string $event;
private string $target;
private DateTimeInterface $created;
private DateTimeInterface $modified;
public function setActorId(int $actor_id): self
{
$this->actor_id = $actor_id;
return $this;
}
public function getActorId(): int
{
return $this->actor_id;
}
public function setEvent(string $event): self
{
$this->event = mb_substr($event, 0, 32);
return $this;
}
public function getEvent(): string
{
return $this->event;
}
public function setTarget(string $target): self
{
$this->target = $target;
return $this;
}
public function getTarget(): string
{
return $this->target;
}
public function setCreated(DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getCreated(): DateTimeInterface
{
return $this->created;
}
public function setModified(DateTimeInterface $modified): self
{
$this->modified = $modified;
return $this;
}
public function getModified(): DateTimeInterface
{
return $this->modified;
}
// @codeCoverageIgnoreEnd
// }}} Autocode
public static function schemaDef(): array
{
return [
'name' => 'webhook',
'fields' => [
'actor_id' => ['type' => 'int', 'not null' => true, 'actor who made this hook'],
'event' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the event this is a hook for'],
'target' => ['type' => 'text', 'not null' => true, 'description' => 'the target URL to POST to'],
'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' => ['actor_id', 'event'],
'indexes' => [
'webhook_actor_id_idx' => ['actor_id'],
],
];
}
}