gnu-social/src/Entity/Notice.php

96 lines
5.3 KiB
PHP
Raw Normal View History

<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/soci
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as publ
// 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 Li
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Entity;
/**
* Entity for notices
*
* @category DB
* @package GNUsocial
*
* @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 Hugo Sales <hugo@fc.up.pt>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class Notice
{
// {{{ Autocode
// }}} Autocode
public static function schemaDef(): array
{
$def = [
'fields' => [
'id' => ['type' => 'serial', 'not null' => true, 'description' => 'unique identifier'],
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'who made the update'],
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'],
'content' => ['type' => 'text', 'description' => 'update content', 'collate' => 'utf8mb4_general_ci'],
'rendered' => ['type' => 'text', 'description' => 'HTML version of the content'],
'url' => ['type' => 'varchar', 'length' => 191, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
'reply_to' => ['type' => 'int', 'description' => 'notice replied to (usually a guess)'],
'is_local' => ['type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'notice was generated by a user'],
'source' => ['type' => 'varchar', 'length' => 32, 'description' => 'source of comment, like "web", "im", or "clientname"'],
'conversation' => ['type' => 'int', 'description' => 'the local numerical conversation id'],
'repeat_of' => ['type' => 'int', 'description' => 'notice this is a repeat of'],
'object_type' => ['type' => 'varchar', 'length' => 191, 'description' => 'URI representing activity streams object type', 'default' => null],
'verb' => ['type' => 'varchar', 'length' => 191, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'],
'scope' => ['type' => 'int',
'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = followers; 16 = messages; null = default', ],
],
'primary key' => ['id'],
'unique keys' => [
'notice_uri_key' => ['uri'],
],
'foreign keys' => [
'notice_profile_id_fkey' => ['profile', ['profile_id' => 'id']],
'notice_reply_to_fkey' => ['notice', ['reply_to' => 'id']],
'notice_conversation_fkey' => ['conversation', ['conversation' => 'id']], // note... used to refer to notice.id
'notice_repeat_of_fkey' => ['notice', ['repeat_of' => 'id']], // @fixme: what about repeats of deleted notices?
],
'indexes' => [
'notice_created_id_is_local_idx' => ['created', 'id', 'is_local'],
'notice_profile_id_idx' => ['profile_id', 'created', 'id'],
'notice_is_local_created_profile_id_idx' => ['is_local', 'created', 'profile_id'],
'notice_repeat_of_created_id_idx' => ['repeat_of', 'created', 'id'],
'notice_conversation_created_id_idx' => ['conversation', 'created', 'id'],
'notice_object_type_idx' => ['object_type'],
'notice_verb_idx' => ['verb'],
'notice_profile_id_verb_idx' => ['profile_id', 'verb'],
'notice_url_idx' => ['url'], // Qvitter wants this
'notice_replyto_idx' => ['reply_to'],
],
];
// TODO
// if (common_config('search', 'type') == 'fulltext') {
// $def['fulltext indexes'] = ['content' => ['content']];
// }
return $def;
}
}