2021-12-11 03:23:03 +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\Conversation\Entity ;
2022-03-27 23:19:09 +09:00
use App\Core\DB ;
2021-12-11 03:23:03 +09:00
use App\Core\Entity ;
2022-03-28 00:43:59 +09:00
use App\Core\Router ;
2021-12-11 03:23:03 +09:00
/**
* Entity class for Conversations
*
* @ category DB
* @ package GNUsocial
*
* @ author Zach Copley < zach @ status . net >
* @ author Mikael Nordfeldth < mmn @ hethane . se >
* @ copyright 2010 StatusNet Inc .
* @ copyright 2009 - 2014 Free Software Foundation , Inc http :// www . fsf . org
* @ author Hugo Sales < hugo @ hsal . es >
* @ author Eliseu Amaro < mail @ eliseuama . ro >
* @ 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 Conversation extends Entity
{
// {{{ Autocode
// @codeCoverageIgnoreStart
private int $id ;
2021-12-11 08:09:39 +09:00
private int $initial_note_id ;
2021-12-11 03:23:03 +09:00
public function setId ( int $id ) : self
{
$this -> id = $id ;
return $this ;
}
public function getId () : int
{
return $this -> id ;
}
2021-12-11 08:09:39 +09:00
public function setInitialNoteId ( int $initial_note_id ) : self
2021-12-11 03:23:03 +09:00
{
2021-12-11 08:09:39 +09:00
$this -> initial_note_id = $initial_note_id ;
2021-12-11 03:23:03 +09:00
return $this ;
}
2021-12-11 08:09:39 +09:00
public function getInitialNoteId () : int
2021-12-11 03:23:03 +09:00
{
2021-12-11 08:09:39 +09:00
return $this -> initial_note_id ;
2021-12-11 03:23:03 +09:00
}
// @codeCoverageIgnoreEnd
// }}} Autocode
2021-12-24 01:20:52 +09:00
public function getUrl ( int $type = Router :: ABSOLUTE_URL ) : string
{
return Router :: url ( 'conversation' , [ 'conversation_id' => $this -> getId ()], $type );
}
public function getUri () : string
{
return $this -> getUrl ( type : Router :: ABSOLUTE_URL );
}
2021-12-11 03:23:03 +09:00
public static function schemaDef () : array
{
return [
'name' => 'conversation' ,
'fields' => [
2021-12-20 02:43:43 +09:00
'id' => [ 'type' => 'serial' , 'not null' => true , 'description' => 'Serial identifier, since any additional meaning would require updating its value for every reply upon receiving a new aparent root' ],
'initial_note_id' => [ 'type' => 'int' , 'foreign key' => true , 'target' => 'Note.id' , 'multiplicity' => 'one to one' , 'not null' => true , 'description' => 'Initial note seen on this host for this conversation' ],
2021-12-11 03:23:03 +09:00
],
2021-12-24 01:20:52 +09:00
'primary key' => [ 'id' ],
2021-12-11 03:23:03 +09:00
'foreign keys' => [
2021-12-11 08:09:39 +09:00
'initial_note_id_to_id_fkey' => [ 'note' , [ 'initial_note_id' => 'id' ]],
2021-12-11 03:23:03 +09:00
],
];
}
}