[MODULE] Move 'foreign' entities from core to a module

This commit is contained in:
Hugo Sales 2020-06-30 18:26:03 +00:00 committed by Hugo Sales
parent 97b583aee7
commit 4d92915846
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
4 changed files with 581 additions and 0 deletions

View File

@ -0,0 +1,205 @@
<?php
// {{{ 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 Module\Entity;
use DateTimeInterface;
/**
* Entity for user's foreign profile
*
* @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 ForeignLink
{
// {{{ Autocode
private int $user_id;
private int $foreign_id;
private int $service;
private ?string $credentials;
private int $noticesync;
private int $friendsync;
private int $profilesync;
private ?DateTimeInterface $last_noticesync;
private ?DateTimeInterface $last_friendsync;
private DateTimeInterface $created;
private DateTimeInterface $modified;
public function setUserId(int $user_id): self
{
$this->user_id = $user_id;
return $this;
}
public function getUserId(): int
{
return $this->user_id;
}
public function setForeignId(int $foreign_id): self
{
$this->foreign_id = $foreign_id;
return $this;
}
public function getForeignId(): int
{
return $this->foreign_id;
}
public function setService(int $service): self
{
$this->service = $service;
return $this;
}
public function getService(): int
{
return $this->service;
}
public function setCredentials(?string $credentials): self
{
$this->credentials = $credentials;
return $this;
}
public function getCredentials(): ?string
{
return $this->credentials;
}
public function setNoticesync(int $noticesync): self
{
$this->noticesync = $noticesync;
return $this;
}
public function getNoticesync(): int
{
return $this->noticesync;
}
public function setFriendsync(int $friendsync): self
{
$this->friendsync = $friendsync;
return $this;
}
public function getFriendsync(): int
{
return $this->friendsync;
}
public function setProfilesync(int $profilesync): self
{
$this->profilesync = $profilesync;
return $this;
}
public function getProfilesync(): int
{
return $this->profilesync;
}
public function setLastNoticesync(?DateTimeInterface $last_noticesync): self
{
$this->last_noticesync = $last_noticesync;
return $this;
}
public function getLastNoticesync(): ?DateTimeInterface
{
return $this->last_noticesync;
}
public function setLastFriendsync(?DateTimeInterface $last_friendsync): self
{
$this->last_friendsync = $last_friendsync;
return $this;
}
public function getLastFriendsync(): ?DateTimeInterface
{
return $this->last_friendsync;
}
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;
}
// }}} Autocode
public static function schemaDef(): array
{
return [
'name' => 'foreign_link',
'fields' => [
'user_id' => ['type' => 'int', 'not null' => true, 'description' => 'link to user on this system, if exists'],
'foreign_id' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'link to user on foreign service, if exists'],
'service' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to service'],
'credentials' => ['type' => 'varchar', 'length' => 191, 'description' => 'authc credentials, typically a password'],
'noticesync' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'notice synchronization, bit 1 = sync outgoing, bit 2 = sync incoming, bit 3 = filter local replies'],
'friendsync' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 2, 'description' => 'friend synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'],
'profilesync' => ['type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'profile synchronization, bit 1 = sync outgoing, bit 2 = sync incoming'],
'last_noticesync' => ['type' => 'datetime', 'description' => 'last time notices were imported'],
'last_friendsync' => ['type' => 'datetime', 'description' => 'last time friends were imported'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
],
'primary key' => ['user_id', 'foreign_id', 'service'],
'foreign keys' => [
'foreign_link_user_id_fkey' => ['user', ['user_id' => 'id']],
'foreign_link_foreign_id_fkey' => ['foreign_user', ['foreign_id' => 'id', 'service' => 'service']],
'foreign_link_service_fkey' => ['foreign_service', ['service' => 'id']],
],
'indexes' => [
'foreign_user_user_id_idx' => ['user_id'],
],
];
}
}

View File

@ -0,0 +1,122 @@
<?php
// {{{ 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 Module\Entity;
use DateTimeInterface;
/**
* Entity for foreign services
*
* @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 ForeignService
{
// {{{ Autocode
private int $id;
private string $name;
private ?string $description;
private DateTimeInterface $created;
private DateTimeInterface $modified;
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getId(): int
{
return $this->id;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
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;
}
// }}} Autocode
public static function schemaDef(): array
{
return [
'name' => 'foreign_service',
'fields' => [
'id' => ['type' => 'int', 'not null' => true, 'description' => 'numeric key for service'],
'name' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'name of the service'],
'description' => ['type' => 'varchar', 'length' => 191, 'description' => 'description'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
],
'primary key' => ['id'],
'unique keys' => [
'foreign_service_name_key' => ['name'],
],
];
}
}

View File

@ -0,0 +1,116 @@
<?php
// {{{ 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 Module\Entity;
use DateTimeInterface;
/**
* Entity for user's foreign subscriptions
*
* @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 ForeignSubscription
{
// {{{ Autocode
private int $service;
private int $subscriber;
private int $subscribed;
private DateTimeInterface $created;
public function setService(int $service): self
{
$this->service = $service;
return $this;
}
public function getService(): int
{
return $this->service;
}
public function setSubscriber(int $subscriber): self
{
$this->subscriber = $subscriber;
return $this;
}
public function getSubscriber(): int
{
return $this->subscriber;
}
public function setSubscribed(int $subscribed): self
{
$this->subscribed = $subscribed;
return $this;
}
public function getSubscribed(): int
{
return $this->subscribed;
}
public function setCreated(DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getCreated(): DateTimeInterface
{
return $this->created;
}
// }}} Autocode
public static function schemaDef(): array
{
return [
'name' => 'foreign_subscription',
'fields' => [
'service' => ['type' => 'int', 'not null' => true, 'description' => 'service where relationship happens'],
'subscriber' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscriber on foreign service'],
'subscribed' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'subscribed user'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
],
'primary key' => ['service', 'subscriber', 'subscribed'],
'foreign keys' => [
'foreign_subscription_service_fkey' => ['foreign_service', ['service' => 'id']],
'foreign_subscription_subscriber_fkey' => ['foreign_user', ['subscriber' => 'id', 'service' => 'service']],
'foreign_subscription_subscribed_fkey' => ['foreign_user', ['subscribed' => 'id', 'service' => 'service']],
],
'indexes' => [
'foreign_subscription_subscriber_idx' => ['service', 'subscriber'],
'foreign_subscription_subscribed_idx' => ['service', 'subscribed'],
],
];
}
}

View File

@ -0,0 +1,138 @@
<?php
// {{{ 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 Module\Entity;
use DateTimeInterface;
/**
* Entity for Foreign Users
*
* @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 ForeignUser
{
// {{{ Autocode
private int $id;
private int $service;
private string $uri;
private ?string $nickname;
private DateTimeInterface $created;
private DateTimeInterface $modified;
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getId(): int
{
return $this->id;
}
public function setService(int $service): self
{
$this->service = $service;
return $this;
}
public function getService(): int
{
return $this->service;
}
public function setUri(string $uri): self
{
$this->uri = $uri;
return $this;
}
public function getUri(): string
{
return $this->uri;
}
public function setNickname(?string $nickname): self
{
$this->nickname = $nickname;
return $this;
}
public function getNickname(): ?string
{
return $this->nickname;
}
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;
}
// }}} Autocode
public static function schemaDef(): array
{
return [
'name' => 'foreign_user',
'fields' => [
'id' => ['type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'unique numeric key on foreign service'],
'service' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to service'],
'uri' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'identifying URI'],
'nickname' => ['type' => 'varchar', 'length' => 191, 'description' => 'nickname on foreign service'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
],
'primary key' => ['id', 'service'],
'foreign keys' => [
'foreign_user_service_fkey' => ['foreign_service', ['service' => 'id']],
],
'unique keys' => [
'foreign_user_uri_key' => ['uri'],
],
];
}
}