2022-02-16 15:56:59 +09:00
< ? 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 Component\Notification\Entity ;
use App\Core\Entity ;
/**
2022-03-14 03:23:19 +09:00
* Entity for object attentions
*
* An attention is a form of persistent notification .
* It exists together and for as long as the object it belongs to .
* Creating an attention requires creating a Notification .
2022-02-16 15:56:59 +09:00
*
* @ category DB
* @ package GNUsocial
*
2022-03-14 03:23:19 +09:00
* @ author Zach Copley < zach @ status . net >
* @ copyright 2010 StatusNet Inc .
* @ author Mikael Nordfeldth < mmn @ hethane . se >
* @ copyright 2009 - 2014 Free Software Foundation , Inc http :// www . fsf . org
* @ author Diogo Peralta Cordeiro <@ diogo . site >
* @ copyright 2021 - 2022 Free Software Foundation , Inc http :// www . fsf . org
2022-02-16 15:56:59 +09:00
* @ license https :// www . gnu . org / licenses / agpl . html GNU AGPL v3 or later
*/
class Attention extends Entity
{
// {{{ Autocode
// @codeCoverageIgnoreStart
2022-03-14 03:23:19 +09:00
private string $object_type ;
private int $object_id ;
2022-02-16 15:56:59 +09:00
private int $target_id ;
2022-03-14 03:23:19 +09:00
public function setObjectType ( string $object_type ) : self
{
$this -> object_type = mb_substr ( $object_type , 0 , 32 );
return $this ;
}
public function getObjectType () : string
{
return $this -> object_type ;
}
public function setObjectId ( int $object_id ) : self
2022-02-16 15:56:59 +09:00
{
2022-03-14 03:23:19 +09:00
$this -> object_id = $object_id ;
2022-02-16 15:56:59 +09:00
return $this ;
}
2022-03-14 03:23:19 +09:00
public function getObjectId () : int
2022-02-16 15:56:59 +09:00
{
2022-03-14 03:23:19 +09:00
return $this -> object_id ;
2022-02-16 15:56:59 +09:00
}
public function setTargetId ( int $target_id ) : self
{
$this -> target_id = $target_id ;
return $this ;
}
public function getTargetId () : int
{
return $this -> target_id ;
}
// @codeCoverageIgnoreEnd
// }}} Autocode
public static function schemaDef () : array
{
return [
2022-03-14 03:23:19 +09:00
'name' => 'attention' ,
'description' => 'Attentions to actors (these are not mentions)' ,
2022-02-16 15:56:59 +09:00
'fields' => [
2022-03-14 03:23:19 +09:00
'object_type' => [ 'type' => 'varchar' , 'length' => 32 , 'not null' => true , 'description' => 'the name of the table this object refers to' ],
'object_id' => [ 'type' => 'int' , 'not null' => true , 'description' => 'id in the referenced table' ],
'target_id' => [ 'type' => 'int' , 'foreign key' => true , 'target' => 'Actor.id' , 'multiplicity' => 'one to one' , 'not null' => true , 'description' => 'actor_id for feed receiver' ],
2022-02-16 15:56:59 +09:00
],
2022-03-14 03:23:19 +09:00
'primary key' => [ 'object_type' , 'object_id' , 'target_id' ],
2022-02-16 15:56:59 +09:00
'indexes' => [
2022-03-14 03:23:19 +09:00
'attention_object_id_idx' => [ 'object_id' ],
2022-02-16 15:56:59 +09:00
'attention_target_id_idx' => [ 'target_id' ],
],
];
}
}