[ENTITY] Refactor Follow as Subscription
This commit is contained in:
parent
68c6dd1ba9
commit
f98afd15ce
@ -52,7 +52,7 @@ class Network extends Controller
|
||||
private $public_scope = VisibilityScope::PUBLIC;
|
||||
private $instance_scope = VisibilityScope::PUBLIC | VisibilityScope::SITE;
|
||||
private $message_scope = VisibilityScope::MESSAGE;
|
||||
private $follower_scope = VisibilityScope::PUBLIC | VisibilityScope::FOLLOWER;
|
||||
private $subscriber_scope = VisibilityScope::PUBLIC | VisibilityScope::SUBSCRIBER;
|
||||
|
||||
public function public(Request $request)
|
||||
{
|
||||
@ -80,9 +80,9 @@ class Network extends Controller
|
||||
-- Select notes from:
|
||||
select note.* from note left join -- left join ensures all returned notes' ids are not null
|
||||
(
|
||||
-- Followed by target
|
||||
select n.id from note n inner join follow f on n.actor_id = f.followed
|
||||
where f.follower = :target_actor_id
|
||||
-- Subscribed by target
|
||||
select n.id from note n inner join subscription f on n.actor_id = f.subscribed
|
||||
where f.subscriber = :target_actor_id
|
||||
union all
|
||||
-- Replies to notes by target
|
||||
select n.id from note n inner join note nr on nr.id = nr.reply_to
|
||||
@ -90,7 +90,7 @@ class Network extends Controller
|
||||
-- Notifications to target
|
||||
select a.activity_id from notification a inner join note n on a.activity_id = n.id
|
||||
union all
|
||||
-- Notes in groups target follows
|
||||
-- Notes in groups target subscriptions
|
||||
select gi.activity_id from group_inbox gi inner join group_member gm on gi.group_id = gm.group_id
|
||||
where gm.actor_id = :target_actor_id
|
||||
)
|
||||
|
@ -12,7 +12,7 @@ use function App\Core\I18n\_m;
|
||||
use App\Core\Log;
|
||||
use App\Core\VisibilityScope;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Follow;
|
||||
use App\Entity\Subscription;
|
||||
use App\Entity\LocalUser;
|
||||
use App\Entity\Note;
|
||||
use App\Security\Authenticator;
|
||||
@ -145,8 +145,8 @@ class Security extends Controller
|
||||
DB::persistWithSameId(
|
||||
$actor,
|
||||
$user,
|
||||
// Self follow
|
||||
fn (int $id) => DB::persist(Follow::create(['follower' => $id, 'followed' => $id])),
|
||||
// Self subscription
|
||||
fn (int $id) => DB::persist(Subscription::create(['subscriber' => $id, 'subscribed' => $id])),
|
||||
);
|
||||
|
||||
Event::handle('SuccessfulLocalUserRegistration', [$actor, $user]);
|
||||
|
@ -173,16 +173,16 @@ class UserPanel extends AbstractController
|
||||
];
|
||||
|
||||
$help = [
|
||||
'target_actor_id' => 'If specified, these settings apply only to these profiles (comma- or space-separated list)',
|
||||
'activity_by_followed' => 'Notify me when someone I follow has new activity',
|
||||
'mention' => 'Notify me when mentions me in a notice',
|
||||
'reply' => 'Notify me when someone replies to a notice made by me',
|
||||
'follow' => 'Notify me when someone follows me or asks for permission to do so',
|
||||
'favorite' => 'Notify me when someone favorites one of my notices',
|
||||
'nudge' => 'Notify me when someone nudges me',
|
||||
'dm' => 'Notify me when someone sends me a direct message',
|
||||
'post_on_status_change' => 'Post a notice when my status in this service changes',
|
||||
'enable_posting' => 'Enable posting from this service',
|
||||
'target_actor_id' => 'If specified, these settings apply only to these profiles (comma- or space-separated list)',
|
||||
'activity_by_subscribed' => 'Notify me when someone I subscribed has new activity',
|
||||
'mention' => 'Notify me when mentions me in a notice',
|
||||
'reply' => 'Notify me when someone replies to a notice made by me',
|
||||
'subscription' => 'Notify me when someone subscribes to me or asks for permission to do so',
|
||||
'favorite' => 'Notify me when someone favorites one of my notices',
|
||||
'nudge' => 'Notify me when someone nudges me',
|
||||
'dm' => 'Notify me when someone sends me a direct message',
|
||||
'post_on_status_change' => 'Post a notice when my status in this service changes',
|
||||
'enable_posting' => 'Enable posting from this service',
|
||||
];
|
||||
|
||||
switch ($type_str) {
|
||||
|
@ -29,7 +29,7 @@ class VisibilityScope extends Bitmap
|
||||
public const SITE = 2;
|
||||
public const ADDRESSEE = 4;
|
||||
public const GROUP = 8;
|
||||
public const FOLLOWER = 16;
|
||||
public const SUBSCRIBER = 16;
|
||||
public const MESSAGE = 32;
|
||||
|
||||
public static int $instance_scope = self::PUBLIC | self::SITE;
|
||||
|
@ -6,7 +6,7 @@ namespace App\DataFixtures;
|
||||
|
||||
use App\Core\VisibilityScope;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Follow;
|
||||
use App\Entity\Subscription;
|
||||
use App\Entity\GroupInbox;
|
||||
use App\Entity\GroupMember;
|
||||
use App\Entity\LocalGroup;
|
||||
@ -34,15 +34,15 @@ class CoreFixtures extends Fixture
|
||||
$ent->{$method}($actor->getId());
|
||||
$local_entities[$nick] = $ent;
|
||||
$manager->persist($ent);
|
||||
// Add self follows
|
||||
$manager->persist(Follow::create(['follower' => $actor->getId(), 'followed' => $actor->getId()]));
|
||||
// Add self subscriptions
|
||||
$manager->persist(Subscription::create(['subscriber' => $actor->getId(), 'subscribed' => $actor->getId()]));
|
||||
$actors[$nick] = $actor;
|
||||
}
|
||||
|
||||
$n = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'some content']);
|
||||
$manager->persist($n);
|
||||
$notes[] = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'some other content', 'reply_to' => $n->getId()]);
|
||||
$notes[] = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER]);
|
||||
$notes[] = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'private note', 'scope' => VisibilityScope::SUBSCRIBER]);
|
||||
$notes[] = $group_note = Note::create(['actor_id' => $actors['taken_user']->getId(), 'content' => 'group note', 'scope' => VisibilityScope::GROUP]);
|
||||
foreach ($notes as $note) {
|
||||
$manager->persist($note);
|
||||
|
@ -270,25 +270,25 @@ class Actor extends Entity
|
||||
public function getSubscribersCount()
|
||||
{
|
||||
return Cache::get(
|
||||
'followers-' . $this->id,
|
||||
'subscribers-' . $this->id,
|
||||
function () {
|
||||
return DB::dql(
|
||||
'select count(f) from App\Entity\Follow f where f.followed = :followed',
|
||||
['followed' => $this->id],
|
||||
)[0][1] - 1; // Remove self follow
|
||||
'select count(f) from App\Entity\Subscription f where f.subscribed = :subscribed',
|
||||
['subscribed' => $this->id],
|
||||
)[0][1] - 1; // Remove self subscription
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public function getSubscriptionsCount()
|
||||
public function getSubscribedCount()
|
||||
{
|
||||
return Cache::get(
|
||||
'followed-' . $this->id,
|
||||
'subscribed-' . $this->id,
|
||||
function () {
|
||||
return DB::dql(
|
||||
'select count(f) from App\Entity\Follow f where f.follower = :follower',
|
||||
['follower' => $this->id],
|
||||
)[0][1] - 1; // Remove self follow
|
||||
'select count(f) from App\Entity\Subscription f where f.subscriber = :subscriber',
|
||||
['subscriber' => $this->id],
|
||||
)[0][1] - 1; // Remove self subscription
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -317,8 +317,8 @@ class Actor extends Entity
|
||||
fn () => DB::dql(
|
||||
<<<'EOF'
|
||||
select a from actor a where
|
||||
a.id in (select fa.followed from follow fa join actor aa with fa.followed = aa.id where fa.follower = :actor_id and aa.nickname = :nickname) or
|
||||
a.id in (select fb.follower from follow fb join actor ab with fb.follower = ab.id where fb.followed = :actor_id and ab.nickname = :nickname) or
|
||||
a.id in (select fa.subscibed from subscription fa join actor aa with fa.subscibed = aa.id where fa.subsciber = :actor_id and aa.nickname = :nickname) or
|
||||
a.id in (select fb.subsciber from subscription fb join actor ab with fb.subsciber = ab.id where fb.subscibed = :actor_id and ab.nickname = :nickname) or
|
||||
a.nickname = :nickname
|
||||
EOF,
|
||||
['nickname' => $nickname, 'actor_id' => $this->getId()],
|
||||
|
@ -36,7 +36,7 @@ use DateTimeInterface;
|
||||
* @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 ActorTagFollow extends Entity
|
||||
class ActorTagSubscription extends Entity
|
||||
{
|
||||
// {{{ Autocode
|
||||
// @codeCoverageIgnoreStart
|
||||
@ -95,18 +95,18 @@ class ActorTagFollow extends Entity
|
||||
public static function schemaDef(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'actor_tag_follow',
|
||||
'name' => 'actor_tag_subscription',
|
||||
'fields' => [
|
||||
'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_follow_actor_id_fkey', 'not null' => true, 'description' => 'foreign key to actor table'],
|
||||
'actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_subscription_actor_id_fkey', 'not null' => true, 'description' => 'foreign key to actor table'],
|
||||
'actor_tag' => ['type' => 'int', // 'foreign key' => true, 'target' => 'ActorTag.tag', 'multiplicity' => 'one to one', // tag can't unique, but doctrine doesn't understand this
|
||||
'name' => 'actor_tag_follow_actor_tag_fkey', 'not null' => true, 'description' => 'foreign key to actor_tag', ],
|
||||
'name' => 'actor_tag_subscription_actor_tag_fkey', 'not null' => true, 'description' => 'foreign key to actor_tag', ],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['actor_tag_id', 'actor_id'],
|
||||
'indexes' => [
|
||||
'actor_tag_follow_actor_id_idx' => ['actor_id'],
|
||||
'actor_tag_follow_created_idx' => ['created'],
|
||||
'actor_tag_subscription_actor_id_idx' => ['actor_id'],
|
||||
'actor_tag_subscription_created_idx' => ['created'],
|
||||
],
|
||||
];
|
||||
}
|
@ -62,8 +62,8 @@ class LocalUser extends Entity implements UserInterface
|
||||
private ?int $sms_carrier;
|
||||
private ?string $sms_email;
|
||||
private ?string $uri;
|
||||
private ?bool $auto_follow_back;
|
||||
private ?int $follow_policy;
|
||||
private ?bool $auto_subscribe_back;
|
||||
private ?int $subscription_policy;
|
||||
private ?bool $is_stream_private;
|
||||
private DateTimeInterface $created;
|
||||
private DateTimeInterface $modified;
|
||||
@ -189,26 +189,26 @@ class LocalUser extends Entity implements UserInterface
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
public function setAutoFollowBack(?bool $auto_follow_back): self
|
||||
public function setAutoSubscribeBack(?bool $auto_subscribe_back): self
|
||||
{
|
||||
$this->auto_follow_back = $auto_follow_back;
|
||||
$this->auto_subscribe_back = $auto_subscribe_back;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAutoFollowBack(): ?bool
|
||||
public function getAutoSubscribeBack(): ?bool
|
||||
{
|
||||
return $this->auto_follow_back;
|
||||
return $this->auto_subscribe_back;
|
||||
}
|
||||
|
||||
public function setFollowPolicy(?int $follow_policy): self
|
||||
public function setSubscriptionPolicy(?int $subscription_policy): self
|
||||
{
|
||||
$this->follow_policy = $follow_policy;
|
||||
$this->subscription_policy = $subscription_policy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollowPolicy(): ?int
|
||||
public function getSubscriptionPolicy(): ?int
|
||||
{
|
||||
return $this->follow_policy;
|
||||
return $this->subscription_policy;
|
||||
}
|
||||
|
||||
public function setIsStreamPrivate(?bool $is_stream_private): self
|
||||
@ -382,9 +382,9 @@ class LocalUser extends Entity implements UserInterface
|
||||
'sms_carrier' => ['type' => 'int', 'foreign key' => true, 'target' => 'SmsCarrier.id', 'multiplicity' => 'one to one', 'description' => 'foreign key to sms_carrier'],
|
||||
'sms_email' => ['type' => 'varchar', 'length' => 191, 'description' => 'built from sms and carrier (see sms_carrier)'],
|
||||
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'],
|
||||
'auto_follow_back' => ['type' => 'bool', 'default' => false, 'description' => 'automatically follow users who follow us'],
|
||||
'follow_policy' => ['type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can follow; 1 = require approval'],
|
||||
'is_stream_private' => ['type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to followers only'],
|
||||
'auto_subscribe_back' => ['type' => 'bool', 'default' => false, 'description' => 'automatically subscribe to users who subscribed us'],
|
||||
'subscription_policy' => ['type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'],
|
||||
'is_stream_private' => ['type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to subscribers only'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
],
|
||||
|
@ -314,7 +314,7 @@ class Note extends Entity
|
||||
$scope = VisibilityScope::create($this->scope);
|
||||
return $scope->public
|
||||
|| (!\is_null($a) && (
|
||||
($scope->follower && 0 != DB::count('follow', ['follower' => $a->getId(), 'followed' => $this->actor_id]))
|
||||
($scope->subscriber && 0 != DB::count('subscription', ['subscriber' => $a->getId(), 'subscribed' => $this->actor_id]))
|
||||
|| ($scope->addressee && 0 != DB::count('notification', ['activity_id' => $this->id, 'actor_id' => $a->getId()]))
|
||||
|| ($scope->group && [] != DB::dql(
|
||||
'select m from group_member m '
|
||||
@ -350,7 +350,7 @@ class Note extends Entity
|
||||
'source' => ['type' => 'varchar', 'foreign key' => true, 'length' => 32, 'target' => 'NoteSource.code', 'multiplicity' => 'many to one', 'description' => 'fkey to source of note, like "web", "im", or "clientname"'],
|
||||
'conversation' => ['type' => 'int', 'foreign key' => true, 'target' => 'Conversation.id', 'multiplicity' => 'one to one', 'description' => 'the local conversation id'],
|
||||
// 'repeat_of' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'description' => 'note this is a repeat of'],
|
||||
'scope' => ['type' => 'int', 'not null' => true, 'default' => VisibilityScope::PUBLIC, 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = followers; 16 = messages; null = default'],
|
||||
'scope' => ['type' => 'int', 'not null' => true, 'default' => VisibilityScope::PUBLIC, 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = groups; 8 = subscribers; 16 = messages; null = default'],
|
||||
'url' => ['type' => 'text', 'description' => 'Permalink to Note'],
|
||||
'language' => ['type' => 'int', 'foreign key' => true, 'target' => 'Language.id', 'multiplicity' => 'one to many', 'description' => 'The language for this note'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
|
@ -36,35 +36,35 @@ use DateTimeInterface;
|
||||
* @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 Follow extends Entity
|
||||
class Subscription extends Entity
|
||||
{
|
||||
// {{{ Autocode
|
||||
// @codeCoverageIgnoreStart
|
||||
private int $follower;
|
||||
private int $followed;
|
||||
private int $subscriber;
|
||||
private int $subscribed;
|
||||
private \DateTimeInterface $created;
|
||||
private \DateTimeInterface $modified;
|
||||
|
||||
public function setFollower(int $follower): self
|
||||
public function setSubscriber(int $subscriber): self
|
||||
{
|
||||
$this->follower = $follower;
|
||||
$this->subscriber = $subscriber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollower(): int
|
||||
public function getSubscriber(): int
|
||||
{
|
||||
return $this->follower;
|
||||
return $this->subscriber;
|
||||
}
|
||||
|
||||
public function setFollowed(int $followed): self
|
||||
public function setSubscribed(int $subscribed): self
|
||||
{
|
||||
$this->followed = $followed;
|
||||
$this->subscribed = $subscribed;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollowed(): int
|
||||
public function getSubscribed(): int
|
||||
{
|
||||
return $this->followed;
|
||||
return $this->subscribed;
|
||||
}
|
||||
|
||||
public function setCreated(DateTimeInterface $created): self
|
||||
@ -95,17 +95,17 @@ class Follow extends Entity
|
||||
public static function schemaDef(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'follow',
|
||||
'name' => 'subscription',
|
||||
'fields' => [
|
||||
'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'follow_follower_fkey', 'not null' => true, 'description' => 'actor listening'],
|
||||
'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'follow_followed_fkey', 'not null' => true, 'description' => 'actor being listened to'],
|
||||
'subscriber' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'subscrib_subscriber_fkey', 'not null' => true, 'description' => 'actor listening'],
|
||||
'subscribed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'subscrib_subscribed_fkey', 'not null' => true, 'description' => 'actor being listened to'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['follower', 'followed'],
|
||||
'primary key' => ['subscriber', 'subscribed'],
|
||||
'indexes' => [
|
||||
'follow_follower_idx' => ['follower', 'created'],
|
||||
'follow_followed_idx' => ['followed', 'created'],
|
||||
'subscrib_subscriber_idx' => ['subscriber', 'created'],
|
||||
'subscrib_subscribed_idx' => ['subscribed', 'created'],
|
||||
],
|
||||
];
|
||||
}
|
@ -36,34 +36,34 @@ use DateTimeInterface;
|
||||
* @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 FollowQueue extends Entity
|
||||
class SubscriptionQueue extends Entity
|
||||
{
|
||||
// {{{ Autocode
|
||||
// @codeCoverageIgnoreStart
|
||||
private int $follower;
|
||||
private int $followed;
|
||||
private int $subscriber;
|
||||
private int $subscribed;
|
||||
private \DateTimeInterface $created;
|
||||
|
||||
public function setFollower(int $follower): self
|
||||
public function setSubscriber(int $subscriber): self
|
||||
{
|
||||
$this->follower = $follower;
|
||||
$this->subscriber = $subscriber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollower(): int
|
||||
public function getSubscriber(): int
|
||||
{
|
||||
return $this->follower;
|
||||
return $this->subscriber;
|
||||
}
|
||||
|
||||
public function setFollowed(int $followed): self
|
||||
public function setSubscribed(int $subscribed): self
|
||||
{
|
||||
$this->followed = $followed;
|
||||
$this->subscribed = $subscribed;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollowed(): int
|
||||
public function getSubscribed(): int
|
||||
{
|
||||
return $this->followed;
|
||||
return $this->subscribed;
|
||||
}
|
||||
|
||||
public function setCreated(DateTimeInterface $created): self
|
||||
@ -83,17 +83,17 @@ class FollowQueue extends Entity
|
||||
public static function schemaDef(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'follow_queue',
|
||||
'description' => 'Holder for Follow requests awaiting moderation.',
|
||||
'name' => 'subscription_queue',
|
||||
'description' => 'Holder for Subscription requests awaiting moderation.',
|
||||
'fields' => [
|
||||
'follower' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_follower_fkey', 'not null' => true, 'description' => 'actor making the request'],
|
||||
'followed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Follow_queue_followed_fkey', 'not null' => true, 'description' => 'actor being followed'],
|
||||
'subscriber' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Subscription_queue_subscriber_fkey', 'not null' => true, 'description' => 'actor making the request'],
|
||||
'subscribed' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'Subscription_queue_subscribed_fkey', 'not null' => true, 'description' => 'actor being subscribed'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
],
|
||||
'primary key' => ['follower', 'followed'],
|
||||
'primary key' => ['subscriber', 'subscribed'],
|
||||
'indexes' => [
|
||||
'follow_queue_follower_created_idx' => ['follower', 'created'],
|
||||
'follow_queue_followed_created_idx' => ['followed', 'created'],
|
||||
'subscription_queue_subscriber_created_idx' => ['subscriber', 'created'],
|
||||
'subscription_queue_subscribed_created_idx' => ['subscribed', 'created'],
|
||||
],
|
||||
];
|
||||
}
|
@ -39,14 +39,14 @@ class UserNotificationPrefs extends Entity
|
||||
private int $user_id;
|
||||
private string $transport;
|
||||
private ?int $target_actor_id;
|
||||
private bool $activity_by_followed = true;
|
||||
private bool $mention = true;
|
||||
private bool $reply = true;
|
||||
private bool $follow = true;
|
||||
private bool $favorite = true;
|
||||
private bool $nudge = false;
|
||||
private bool $dm = true;
|
||||
private bool $post_on_status_change = false;
|
||||
private bool $activity_by_subscribed = true;
|
||||
private bool $mention = true;
|
||||
private bool $reply = true;
|
||||
private bool $subscription = true;
|
||||
private bool $favorite = true;
|
||||
private bool $nudge = false;
|
||||
private bool $dm = true;
|
||||
private bool $post_on_status_change = false;
|
||||
private ?bool $enable_posting;
|
||||
private \DateTimeInterface $created;
|
||||
private \DateTimeInterface $modified;
|
||||
@ -84,15 +84,15 @@ class UserNotificationPrefs extends Entity
|
||||
return $this->target_actor_id;
|
||||
}
|
||||
|
||||
public function setActivityByFollowed(bool $activity_by_followed): self
|
||||
public function setActivityBySubscribed(bool $activity_by_subscribed): self
|
||||
{
|
||||
$this->activity_by_followed = $activity_by_followed;
|
||||
$this->activity_by_subscribed = $activity_by_subscribed;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getActivityByFollowed(): bool
|
||||
public function getActivityBySubscribed(): bool
|
||||
{
|
||||
return $this->activity_by_followed;
|
||||
return $this->activity_by_subscribed;
|
||||
}
|
||||
|
||||
public function setMention(bool $mention): self
|
||||
@ -117,15 +117,15 @@ class UserNotificationPrefs extends Entity
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
public function setFollow(bool $follow): self
|
||||
public function setSubscription(bool $subscription): self
|
||||
{
|
||||
$this->follow = $follow;
|
||||
$this->subscription = $subscription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFollow(): bool
|
||||
public function getSubscription(): bool
|
||||
{
|
||||
return $this->follow;
|
||||
return $this->subscription;
|
||||
}
|
||||
|
||||
public function setFavorite(bool $favorite): self
|
||||
@ -213,20 +213,20 @@ class UserNotificationPrefs extends Entity
|
||||
return [
|
||||
'name' => 'user_notification_prefs',
|
||||
'fields' => [
|
||||
'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true],
|
||||
'transport' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex email. xmpp, aim)'],
|
||||
'target_actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'default' => null, 'description' => 'If not null, settings are specific only to a given actors'],
|
||||
'activity_by_followed' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when a new activity by someone we follow is made'],
|
||||
'mention' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when mentioned by someone we do not follow'],
|
||||
'reply' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when someone replies to a notice made by us'],
|
||||
'follow' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone follows us'],
|
||||
'favorite' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone favorites a notice by us'],
|
||||
'nudge' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone nudges us'],
|
||||
'dm' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone sends us a direct message'],
|
||||
'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'],
|
||||
'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'user_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'LocalUser.id', 'multiplicity' => 'one to one', 'not null' => true],
|
||||
'transport' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex email. xmpp, aim)'],
|
||||
'target_actor_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'default' => null, 'description' => 'If not null, settings are specific only to a given actors'],
|
||||
'activity_by_subscribed' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when a new activity by someone we subscribe is made'],
|
||||
'mention' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when mentioned by someone we do not subscribe'],
|
||||
'reply' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify when someone replies to a notice made by us'],
|
||||
'subscription' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone subscribes us'],
|
||||
'favorite' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone favorites a notice by us'],
|
||||
'nudge' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Notify someone nudges us'],
|
||||
'dm' => ['type' => 'bool', 'not null' => true, 'default' => true, 'description' => 'Notify someone sends us a direct message'],
|
||||
'post_on_status_change' => ['type' => 'bool', 'not null' => true, 'default' => false, 'description' => 'Post a notice when our status in service changes'],
|
||||
'enable_posting' => ['type' => 'bool', 'default' => true, 'description' => 'Enable posting from this service'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['user_id', 'transport'],
|
||||
'indexes' => [
|
||||
|
@ -61,14 +61,14 @@ abstract class AbstractTransport
|
||||
public function getHelpMessage(int $t): string
|
||||
{
|
||||
switch ($t) {
|
||||
case Notification::NOTICE_BY_FOLLOWED:
|
||||
return _m('Send me alerts of mentions by those I follow through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::NOTICE_BY_SUBSCRIBED:
|
||||
return _m('Send me alerts of mentions by those I subscribe through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::MENTION:
|
||||
return _m('Send me alerts of mentions through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::REPLY:
|
||||
return _m('Send me alerts of replies to my notice through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::FOLLOW:
|
||||
return _m('Send me alerts of new follows through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::SUBSCRIPTION:
|
||||
return _m('Send me alerts of new subscriptions through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::FAVORITE:
|
||||
return _m('Send me alerts of new favorites on my notices through {name}', ['{name}' => $this->getName()]);
|
||||
case Notification::NUDGE:
|
||||
@ -86,14 +86,14 @@ abstract class AbstractTransport
|
||||
public function getLabelMessage(int $t): string
|
||||
{
|
||||
switch ($t) {
|
||||
case Notification::NOTICE_BY_FOLLOWED:
|
||||
case Notification::NOTICE_BY_SUBSCRIBED:
|
||||
return _m('Notify me of new notices');
|
||||
case Notification::MENTION:
|
||||
return _m('Notify me of mentions');
|
||||
case Notification::REPLY:
|
||||
return _m('Notify me of replies');
|
||||
case Notification::FOLLOW:
|
||||
return _m('Notify me of new follows');
|
||||
case Notification::SUBSCRIPTION:
|
||||
return _m('Notify me of new subscriptions');
|
||||
case Notification::FAVORITE:
|
||||
return _m('Notify me of new favorites');
|
||||
case Notification::NUDGE:
|
||||
|
@ -36,13 +36,13 @@ use App\Entity\Actor;
|
||||
|
||||
class Notification
|
||||
{
|
||||
public const NOTICE_BY_FOLLOWED = 1;
|
||||
public const MENTION = 2;
|
||||
public const REPLY = 3;
|
||||
public const FOLLOW = 4;
|
||||
public const FAVORITE = 5;
|
||||
public const NUDGE = 6;
|
||||
public const DM = 7;
|
||||
public const NOTICE_BY_SUBSCRIBED = 1;
|
||||
public const MENTION = 2;
|
||||
public const REPLY = 3;
|
||||
public const SUBSCRIPTION = 4;
|
||||
public const FAVORITE = 5;
|
||||
public const NUDGE = 6;
|
||||
public const DM = 7;
|
||||
|
||||
/**
|
||||
* One of the above constants
|
||||
|
@ -22,7 +22,7 @@
|
||||
</a>
|
||||
|
||||
<section class="profile-info-stats">
|
||||
<div><strong>{{ 'Subscriptions' | trans }}</strong>{{ actor.getSubscriptionsCount() }}</div>
|
||||
<div><strong>{{ 'Subscribed' | trans }}</strong>{{ actor.getSubscribedCount() }}</div>
|
||||
<div><strong>{{ 'Subscribers' | trans }}</strong>{{ actor.getSubscribersCount() }}</div>
|
||||
</section>
|
||||
|
||||
|
@ -48,7 +48,7 @@ class NoteTest extends GNUsocialTestCase
|
||||
$actor2 = DB::findOneBy('actor', ['nickname' => 'taken_group']);
|
||||
$actor3 = DB::findOneBy('actor', ['nickname' => 'some_user']);
|
||||
|
||||
$note_visible_to_1 = DB::findBy('note', ['actor_id' => $actor1->getId(), 'content' => 'private note', 'scope' => VisibilityScope::FOLLOWER], limit: 1)[0];
|
||||
$note_visible_to_1 = DB::findBy('note', ['actor_id' => $actor1->getId(), 'content' => 'private note', 'scope' => VisibilityScope::SUBSCRIBER], limit: 1)[0];
|
||||
static::assertTrue($note_visible_to_1->isVisibleTo($actor1));
|
||||
static::assertFalse($note_visible_to_1->isVisibleTo($actor2));
|
||||
static::assertFalse($note_visible_to_1->isVisibleTo($actor3));
|
||||
|
Loading…
Reference in New Issue
Block a user