Skip to content

Commit 6694fcf

Browse files
committed
Add Indexable setting for users and magazines
- Add an option in the general settings for users and magazines to be indexable. Since it was basically the case until now, the default for local users is true. - Add a `noindex` header if the magazine a thread or microblog belongs to, or the author of the thread or microblog are not indexable. (Note: this does not apply to comments, since they are always rendered on the thread or microblog page) - Add the missing storage url to the `.env.test` file. This resulted in a few snapshot changes - Add the testing services to the DI and add the arguments to only use the testing services when the environment is `test` - improve the help text rendering underneath checkboxes and apply it to the other checkbox help text in the admin federation page
1 parent 08a0f9f commit 6694fcf

43 files changed

Lines changed: 161 additions & 26 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ MAILER_DSN=null://default
1717
KBIN_JS_ENABLED=false
1818
KBIN_DEFAULT_LANG=en
1919
KBIN_DOMAIN=kbin.test
20+
KBIN_STORAGE_URL=https://kbin.test/media
2021
ELASTICSEARCH_ENABLED=false
2122
KBIN_API_ITEMS_PER_PAGE=2
2223
KBIN_FEDERATION_ENABLED=true

config/services.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ services:
239239
event: kernel.controller_arguments,
240240
}
241241

242+
# Testing
243+
App\Tests\Service\:
244+
resource: '../tests/Service/'
245+
242246
# Feeds
243247
debril.rss_atom.provider:
244248
class: App\Feed\Provider
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
final class Version20260113103210 extends AbstractMigration
11+
{
12+
public function getDescription(): string
13+
{
14+
return 'Add ap_indexable to ActivityPub actors';
15+
}
16+
17+
public function up(Schema $schema): void
18+
{
19+
$this->addSql('ALTER TABLE magazine ADD ap_indexable BOOLEAN DEFAULT NULL');
20+
$this->addSql('ALTER TABLE "user" ADD ap_indexable BOOLEAN DEFAULT NULL');
21+
// The column should be nullable so that we know whether other software simply does not set this value,
22+
// but for local users and magazines we should only have true and false as options
23+
$this->addSql('UPDATE "user" SET ap_indexable = true WHERE ap_id IS NULL');
24+
$this->addSql('UPDATE magazine SET ap_indexable = true WHERE ap_id IS NULL');
25+
}
26+
27+
public function down(Schema $schema): void
28+
{
29+
$this->addSql('ALTER TABLE "user" DROP ap_indexable');
30+
$this->addSql('ALTER TABLE magazine DROP ap_indexable');
31+
}
32+
}

src/DTO/MagazineDto.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class MagazineDto
4040
public int $postCommentCount = 0;
4141
public bool $isAdult = false;
4242
public bool $isPostingRestrictedToMods = false;
43+
public ?bool $indexable = null;
4344
public ?bool $isUserSubscribed = null;
4445
public ?bool $isBlockedByUser = null;
4546
public ?int $localSubscribers = null;

src/DTO/MagazineRequestDto.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class MagazineRequestDto
1616
public ?bool $isAdult = null;
1717
public ?bool $isPostingRestrictedToMods = null;
1818
public ?bool $discoverable = null;
19+
public ?bool $indexable = null;
1920

2021
public function mergeIntoDto(MagazineDto $dto): MagazineDto
2122
{
@@ -26,6 +27,7 @@ public function mergeIntoDto(MagazineDto $dto): MagazineDto
2627
$dto->isAdult = null !== $this->isAdult ? $this->isAdult : $dto->isAdult;
2728
$dto->isPostingRestrictedToMods = $this->isPostingRestrictedToMods ?? false;
2829
$dto->discoverable = $this->discoverable ?? $dto->discoverable ?? true;
30+
$dto->indexable = $this->indexable ?? $dto->indexable ?? true;
2931

3032
return $dto;
3133
}

src/DTO/MagazineResponseDto.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class MagazineResponseDto implements \JsonSerializable
4141
public ?int $localSubscribers = null;
4242
public ?ENotificationStatus $notificationStatus = null;
4343
public ?bool $discoverable = null;
44+
public ?bool $indexable = null;
4445

4546
public static function create(
4647
?ModeratorResponseDto $owner = null,
@@ -69,6 +70,7 @@ public static function create(
6970
bool $isPostingRestrictedToMods = false,
7071
?int $localSubscribers = null,
7172
?bool $discoverable = null,
73+
?bool $indexable = null,
7274
): self {
7375
$dto = new MagazineResponseDto();
7476
$dto->owner = $owner;
@@ -97,6 +99,7 @@ public static function create(
9799
$dto->isPostingRestrictedToMods = $isPostingRestrictedToMods;
98100
$dto->localSubscribers = $localSubscribers;
99101
$dto->discoverable = $discoverable;
102+
$dto->indexable = $indexable;
100103

101104
return $dto;
102105
}
@@ -131,6 +134,7 @@ public function jsonSerialize(): mixed
131134
'localSubscribers' => $this->localSubscribers,
132135
'notificationStatus' => $this->notificationStatus,
133136
'discoverable' => $this->discoverable,
137+
'indexable' => $this->indexable,
134138
];
135139
}
136140
}

src/DTO/MagazineSmallResponseDto.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MagazineSmallResponseDto implements \JsonSerializable
1818
public ?string $apId = null;
1919
public ?string $apProfileId = null;
2020
public ?bool $discoverable = null;
21+
public ?bool $indexable = null;
2122

2223
public function __construct(MagazineDto $dto)
2324
{
@@ -30,6 +31,7 @@ public function __construct(MagazineDto $dto)
3031
$this->apId = $dto->apId;
3132
$this->apProfileId = $dto->apProfileId;
3233
$this->discoverable = $dto->discoverable;
34+
$this->indexable = $dto->indexable;
3335
}
3436

3537
public function jsonSerialize(): mixed
@@ -44,6 +46,7 @@ public function jsonSerialize(): mixed
4446
'apId' => $this->apId,
4547
'apProfileId' => $this->apProfileId,
4648
'discoverable' => $this->discoverable,
49+
'indexable' => $this->indexable,
4750
];
4851
}
4952
}

src/DTO/MagazineUpdateRequestDto.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class MagazineUpdateRequestDto
1717
public ?bool $isAdult = null;
1818
public ?bool $isPostingRestrictedToMods = null;
1919
public ?bool $discoverable = null;
20+
public ?bool $indexable = null;
2021

2122
public function mergeIntoDto(MagazineDto $dto, ImageRepository $imageRepository): MagazineDto
2223
{
@@ -27,6 +28,7 @@ public function mergeIntoDto(MagazineDto $dto, ImageRepository $imageRepository)
2728
$dto->isAdult = null === $this->isAdult ? $this->isAdult : $dto->isAdult;
2829
$dto->isPostingRestrictedToMods = $this->isPostingRestrictedToMods ?? false;
2930
$dto->discoverable = $this->discoverable ?? $dto->discoverable ?? true;
31+
$dto->indexable = $this->indexable ?? $dto->indexable ?? true;
3032

3133
return $dto;
3234
}

src/DTO/UserDto.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class UserDto implements UserDtoInterface
5252
public ?string $applicationText = null;
5353
public ?int $reputationPoints = null;
5454
public ?bool $discoverable = null;
55+
public ?bool $indexable = null;
5556

5657
#[Assert\Callback]
5758
public function validate(
@@ -97,6 +98,7 @@ public static function create(
9798
?string $applicationText = null,
9899
?int $reputationPoints = null,
99100
?bool $discoverable = null,
101+
?bool $indexable = null,
100102
): self {
101103
$dto = new UserDto();
102104
$dto->id = $id;
@@ -116,6 +118,7 @@ public static function create(
116118
$dto->applicationText = $applicationText;
117119
$dto->reputationPoints = $reputationPoints;
118120
$dto->discoverable = $discoverable;
121+
$dto->indexable = $indexable;
119122

120123
return $dto;
121124
}

src/DTO/UserResponseDto.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class UserResponseDto implements \JsonSerializable
2828
public ?string $serverSoftware = null;
2929
public ?string $serverSoftwareVersion = null;
3030
public ?ENotificationStatus $notificationStatus = null;
31+
public ?bool $indexable = null;
3132

3233
/**
3334
* @var int|null this will only be populated on single user retrieves, not on batch ones,
@@ -57,6 +58,7 @@ public function __construct(UserDto $dto)
5758
$this->isGlobalModerator = $dto->isGlobalModerator;
5859
$this->reputationPoints = $dto->reputationPoints;
5960
$this->discoverable = $dto->discoverable;
61+
$this->indexable = $dto->indexable;
6062
}
6163

6264
public function jsonSerialize(): mixed
@@ -82,6 +84,7 @@ public function jsonSerialize(): mixed
8284
'notificationStatus' => $this->notificationStatus,
8385
'reputationPoints' => $this->reputationPoints,
8486
'discoverable' => $this->discoverable,
87+
'indexable' => $this->indexable,
8588
];
8689
}
8790
}

0 commit comments

Comments
 (0)