diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index 6965f9e74..2df9164b6 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -52,6 +52,7 @@ This file documents the platform's features, stack, and stories. Feature entries - [Signed API and devices](#signed-api-and-devices) - [Terminal app](#terminal-app) - [Bug reports and feature requests](#bug-reports-and-feature-requests) + - [Guilds](#guilds) - [Exporting your data](#exporting-your-data) - [Deleting your account](#deleting-your-account) - [Moderation](#moderation) @@ -657,9 +658,13 @@ Successful issue creation is limited to **ten issues per day per user**, shared Sources: [issue command UI](resources/js/components/issue-command.tsx), [issue validation](app/Http/Requests/CreateIssueRequest.php), [issue controller](app/Http/Controllers/IssueController.php), [daily limit](app/Http/Middleware/ThrottleIssues.php), [API issue controller](app/Http/Controllers/Api/IssueController.php). -### Guilds (preview) +### Guilds -Guilds are public groups around hashtags and are not generally available yet. In the preview, matching hashtags become small clickable guild labels; ordinary hashtags still open search. Create a guild from the Guilds overview or a hashtag's search page. From the overview, its display name determines the hashtag: “Laravel 4ever” becomes `#laravel4ever`. Display names and handles each allow up to 60 characters. When claiming a hashtag, the display name must match its letters, numbers and underscores, ignoring case; spaces, punctuation and decorative symbols are ignored, so `/dev/null` is valid for `#devnull`. Accents and underscores remain significant. Its creator joins automatically and maintains its display name, icon and description; a new display name must still match the hashtag, so `#adhd` can become “ADHD” but never another hashtag. Each person can create up to 100 guilds. A guild's name, description and icon pass the same automated moderation as commits before the guild is published or edited. When the moderation flags a new guild or an edit, it waits for an admin to review it instead: nothing of it is public until it is approved, the guild keeps its current details meanwhile, and a rejected submission is discarded. Submitting again for the same hashtag replaces the one still waiting, and new guilds waiting for review count toward the creation limit. +Guilds are public groups around hashtags, where matching hashtags become small clickable guild labels; ordinary hashtags still open search. Create a guild from the Guilds overview or a hashtag's search page. + +From the overview, a guild's display name determines the hashtag: “Laravel 4ever” becomes `#laravel4ever`. Display names and handles each allow up to 60 characters. When claiming a hashtag, the display name must match its letters, numbers and underscores, ignoring case; spaces, punctuation and decorative symbols are ignored, so `/dev/null` is valid for `#devnull`. Accents and underscores remain significant. + +The guild's creator joins automatically and maintains its display name, icon and description; a new display name must still match the hashtag, so `#adhd` can become “ADHD” but never another hashtag. Each person can create up to 100 guilds. A guild's name, description and icon pass the same automated moderation as commits before the guild is published or edited. When the moderation flags a new guild or an edit to an existing guild, it waits for an admin to review it instead: nothing of it is public until it is approved, the guild keeps its current details meanwhile, and a rejected submission is discarded. Submitting again for the same hashtag replaces the one still waiting, and new guilds waiting for review count toward the per-user guild creation limit. The Guilds page lists groups by member count, with 24 guilds per page. Search matches keywords in guild names, handles, and descriptions, ignoring case; a leading `#` is optional. This directory search is keyword-based, not semantic. Click a guild's member count to browse its members: the moderator appears first, labeled “(moderator)”, followed by newest joins, with 50 people per page and Load more for the next page. Joining adds matching commits to Following without following every author and clears any existing mute. When a commit appears only because of a joined guild, it says “because you joined” beside the guild label. Leave a guild to reveal its Mute control. Muting hides matching commits from logs and search, including commits by followed authors. You can still open the guild or a commit directly. @@ -700,7 +705,7 @@ You can sign in with GitHub again later, but start from a new account rather tha As the privacy policy explains, timeout and ban records retain your GitHub account id, reason, and dates after account deletion, so deleting and recreating an account cannot evade those restrictions. Your GitHub account id is also kept until you sign in again, only so that your page doesn't come back as one of a developer not on /dev/null yet. Deleted content may also remain in backups and logs for a period. -For guilds, which are not generally available yet, a moderator removal retains only the GitHub account ID, hashtag and removal date after account deletion, so the same GitHub account cannot reclaim that guild. Guild descriptions, icons and reports are not retained by that restriction. +For guilds, a moderator removal retains only the GitHub account ID, hashtag and removal date after account deletion, so the same GitHub account cannot reclaim that guild. Guild descriptions, icons and reports are not retained by that restriction. Sources: [account deletion confirmation](resources/js/components/delete-user.tsx), [account deletion](app/Actions/DeleteUser.php), [privacy policy](resources/js/pages/privacy/show.tsx). diff --git a/PRODUCT.md b/PRODUCT.md index c0fc1d615..a9c9d6d06 100644 --- a/PRODUCT.md +++ b/PRODUCT.md @@ -40,7 +40,7 @@ What exists, one line each (details in the knowledge base): - **Remotes:** private one-to-one and group messages (orgs), and calls, one-to-one or in an org. - **Notifications:** in-app activity and on-site Remotes alerts by default; off-site browser and PWA notifications require a separate opt-in. Sound is controlled independently and plays while the site is open. - **Search:** developers by name, commits by meaning. -- **Guilds (preview):** public communities around hashtags; creators maintain their display name, icon and description. Not generally available yet. +- **Guilds:** public communities around hashtags; creators maintain their display name, icon and description. - **Emails:** an occasional update the admins write to everyone, or to a filtered audience, with one-click unsubscribe. Never per-activity notifications. - **Safety:** mute, block, reports, and moderation. - **Bots:** Tom answers questions about /dev/null from the knowledge base, the public repository, and aggregate community statistics; World answers "hello world". They use @tom and @world until those GitHub owners sign in, then keep working as @devnull-tom and @devnull-world. diff --git a/app/Services/Features.php b/app/Services/Features.php index 93d9ba33c..c18c715e8 100644 --- a/app/Services/Features.php +++ b/app/Services/Features.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\DB; /** - * Only explicit overrides are stored; guilds default to an admin preview, other features to everyone. + * Only explicit overrides are stored; every feature defaults to everyone, unless adminOnlyByDefault() lists it. */ final readonly class Features { @@ -24,7 +24,7 @@ public function enabled(Feature $feature): bool public function adminOnly(Feature $feature): bool { - return $this->switched()[$feature->value]['admin_only'] ?? $feature === Feature::Guilds; + return $this->switched()[$feature->value]['admin_only'] ?? in_array($feature, $this->adminOnlyByDefault(), true); } public function available(Feature $feature, ?User $user): bool @@ -53,6 +53,18 @@ public function update(Feature $feature, bool $enabled, ?bool $adminOnly = null) Cache::memo()->forget(self::CACHE_KEY); } + /** + * Features that default to admins only until an override opens them. + * + * @return list + */ + private function adminOnlyByDefault(): array + { + return [ + // e.g. Feature::Guilds + ]; + } + /** @return array */ private function switched(): array { diff --git a/resources/js/pages/operations/features.tsx b/resources/js/pages/operations/features.tsx index 0f2501b54..56110dee2 100644 --- a/resources/js/pages/operations/features.tsx +++ b/resources/js/pages/operations/features.tsx @@ -21,7 +21,7 @@ const FEATURES: Record< guilds: { label: 'guilds', description: - 'Public guild pages, creation, editing, and inline hashtag chips. Choose who can use the preview.', + 'Public guild pages, creation, editing, and inline hashtag chips. Choose who can use them.', }, }; diff --git a/tests/Feature/Controllers/Api/CommitControllerTest.php b/tests/Feature/Controllers/Api/CommitControllerTest.php index 2d0348dda..2178f5435 100644 --- a/tests/Feature/Controllers/Api/CommitControllerTest.php +++ b/tests/Feature/Controllers/Api/CommitControllerTest.php @@ -1103,7 +1103,7 @@ return []; }], - 'admin preview' => [function (): array { + 'admins only' => [function (): array { resolve(Features::class)->update(Feature::Guilds, true, adminOnly: true); return []; diff --git a/tests/Feature/Controllers/Api/GuildControllerTest.php b/tests/Feature/Controllers/Api/GuildControllerTest.php index 52c2bada9..d4def13f6 100644 --- a/tests/Feature/Controllers/Api/GuildControllerTest.php +++ b/tests/Feature/Controllers/Api/GuildControllerTest.php @@ -88,11 +88,11 @@ signedApiRequest($this->keyPair, 'GET', route('api-guild.index'))->assertNotFound(); })->with([ - 'admin preview' => [true, true], + 'admins only' => [true, true], 'switched off' => [false, false], ]); -it('lists guilds for admins during the admin preview', function (): void { +it('lists guilds for admins while guilds are admin-only', function (): void { config(['app.admins' => [$this->user->handle]]); resolve(Features::class)->update(Feature::Guilds, true, adminOnly: true); Guild::factory()->create(['handle' => 'rust']); @@ -248,7 +248,7 @@ signedApiRequest($this->keyPair, 'GET', route('api-guild.show', $handle))->assertNotFound(); })->with([ 'unknown guild' => [false, 'go'], - 'admin preview' => [true, 'rust'], + 'admins only' => [true, 'rust'], ]); it('creates a guild from its display name, with the user as its moderator and first member', function (): void { diff --git a/tests/Feature/Controllers/FeatureControllerTest.php b/tests/Feature/Controllers/FeatureControllerTest.php index 2e6cf2439..22b10bf42 100644 --- a/tests/Feature/Controllers/FeatureControllerTest.php +++ b/tests/Feature/Controllers/FeatureControllerTest.php @@ -20,7 +20,10 @@ ->assertOk() ->assertInertia(fn ($page) => $page ->component('operations/features') - ->where('features', [['name' => 'translations', 'enabled' => true, 'admin_only' => false], ['name' => 'guilds', 'enabled' => true, 'admin_only' => true]])); + ->where('features', [ + ['name' => 'translations', 'enabled' => true, 'admin_only' => false], + ['name' => 'guilds', 'enabled' => true, 'admin_only' => false], + ])); }); it('hides the features from non admins', function (): void { @@ -37,7 +40,7 @@ $admin = User::factory()->create(['handle' => 'admin']); $this->actingAs($admin)->get(route('feature.index')) - ->assertInertia(fn ($page) => $page->where('features', [['name' => 'translations', 'enabled' => true, 'admin_only' => false], ['name' => 'guilds', 'enabled' => true, 'admin_only' => true]])); + ->assertInertia(fn ($page) => $page->where('features', [['name' => 'translations', 'enabled' => true, 'admin_only' => false], ['name' => 'guilds', 'enabled' => true, 'admin_only' => false]])); $this->fromRoute('feature.index') ->put(route('feature.update', 'translations'), ['enabled' => false]) @@ -46,7 +49,7 @@ expect(resolve(Features::class)->enabled(Feature::Translations))->toBeFalse(); $this->assertDatabaseHas('features', ['name' => 'translations', 'enabled' => false]); $this->get(route('feature.index')) - ->assertInertia(fn ($page) => $page->where('features', [['name' => 'translations', 'enabled' => false, 'admin_only' => false], ['name' => 'guilds', 'enabled' => true, 'admin_only' => true]])); + ->assertInertia(fn ($page) => $page->where('features', [['name' => 'translations', 'enabled' => false, 'admin_only' => false], ['name' => 'guilds', 'enabled' => true, 'admin_only' => false]])); $this->put(route('feature.update', 'translations'), ['enabled' => true])->assertRedirect(); @@ -91,7 +94,20 @@ $guild = Guild::factory()->create(); Event::fake([UsersUpdated::class]); + // Open by default + $this->actingAs($member)->get(route('guild.show', $guild->handle))->assertOk(); + + // Switch to Admins only + $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => true, 'admin_only' => true])->assertRedirect(); + $this->get(route('guild.show', $guild->handle))->assertOk(); $this->actingAs($member)->get(route('guild.show', $guild->handle))->assertNotFound(); + + // Switch off, keeping Admins for when it's back on + $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => false])->assertRedirect(); + $this->get(route('guild.show', $guild->handle))->assertNotFound(); + $this->assertDatabaseHas('features', ['name' => 'guilds', 'enabled' => false, 'admin_only' => true]); + + // Switch back to everyone (reopened) $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => true, 'admin_only' => false])->assertRedirect(); $this->actingAs($member)->get(route('guild.show', $guild->handle))->assertOk(); $this->post(route('guild.store'), ['name' => 'New Guild', 'description' => 'Open to everyone.', 'emoji' => '💻'])->assertRedirectToRoute('guild.show', 'newguild'); @@ -99,13 +115,11 @@ Event::assertDispatched(UsersUpdated::class, fn (UsersUpdated $event): bool => $event->update === UserUpdate::Guilds && in_array($member->id, $event->userIds, true)); Event::assertDispatched(UsersUpdated::class, fn (UsersUpdated $event): bool => $event->update === UserUpdate::Relationships && in_array($member->id, $event->userIds, true)); - $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => true, 'admin_only' => true])->assertRedirect(); - $this->get(route('guild.show', $guild->handle))->assertOk(); - $this->actingAs($member)->get(route('guild.show', $guild->handle))->assertNotFound(); + // Switch to Disabled $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => false])->assertRedirect(); $this->get(route('guild.show', $guild->handle))->assertNotFound(); $this->actingAs($member)->get(route('guild.show', $guild->handle))->assertNotFound(); - $this->assertDatabaseHas('features', ['name' => 'guilds', 'enabled' => false, 'admin_only' => true]); + $this->assertDatabaseHas('features', ['name' => 'guilds', 'enabled' => false, 'admin_only' => false]); }); it('rejects an invalid audience without changing access', function (): void { diff --git a/tests/Feature/Controllers/GuildControllerTest.php b/tests/Feature/Controllers/GuildControllerTest.php index b7bc58ce7..b862ef3d0 100644 --- a/tests/Feature/Controllers/GuildControllerTest.php +++ b/tests/Feature/Controllers/GuildControllerTest.php @@ -29,6 +29,7 @@ use App\Models\ScheduledCommit; use App\Models\User; use App\Queries\LogCommitsQuery; +use App\Services\Features; use Illuminate\Database\Events\QueryExecuted; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\DB; @@ -91,6 +92,11 @@ }); it('does not let bulletin board context bypass validation', function (string $route, array $payload, bool $admin, string $field): void { + if (! $admin) { + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, true); + } + Guild::factory()->create(['handle' => 'rust']); $this->actingAs(User::factory()->create(['handle' => $admin ? 'admin' : 'member'])) ->postJson(route($route), ['body' => 'Hello', 'guild_handle' => 'rust', 'scheduled_at' => now()->addHour()->toIso8601String(), ...$payload]) @@ -102,7 +108,7 @@ 'empty text' => [['body' => ''], true, 'body'], 'missing guild' => [['guild_handle' => 'missing'], true, 'guild_handle'], 'invalid context' => [['guild_handle' => ['rust']], true, 'guild_handle'], - 'not available' => [[], false, 'guild_handle'], + 'admins only' => [[], false, 'guild_handle'], ]); it('creates a public guild and gives only its creator moderation controls', function (): void { @@ -126,7 +132,9 @@ ->get(route('guild.show', 'jobs'))->assertOk()->assertInertia(fn ($page) => $page->where('canModerate', false)); }); -it('hides guild data and every guild endpoint from ordinary members', function (): void { +it('hides guild data and every guild endpoint from ordinary members while guilds are admin-only', function (): void { + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, true); $user = User::factory()->create(); $guild = Guild::factory()->create(['user_id' => $user->id]); @@ -173,7 +181,7 @@ $this->putJson(route('guild.update', $guild->handle), [])->assertUnauthorized(); }); -it('switches off the entire preview even for its admin creator', function (): void { +it('switches off guilds entirely, even for an admin creator', function (): void { $admin = User::factory()->create(['handle' => 'admin']); $guild = Guild::factory()->create(['user_id' => $admin->id]); $this->actingAs($admin)->put(route('feature.update', Feature::Guilds), ['enabled' => false])->assertRedirect(); @@ -468,8 +476,13 @@ $this->assertDatabaseCount('guilds', 0); }); -it('gates reporting removal and review behind the admin preview', function (bool $disabled): void { +it('gates reporting removal and review behind guild access', function (bool $disabled): void { $user = User::factory()->create(['handle' => $disabled ? 'admin' : 'ordinary']); + if (! $disabled) { + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, true); + } + $guild = Guild::factory()->create(); resolve(CreateGuildReport::class)->handle($user, $guild, 'Unrelated description.'); $report = GuildReport::query()->sole(); @@ -710,7 +723,9 @@ 'large page' => [['page' => 10001], 'page'], ]); -it('guards guild discovery and preferences with the preview flag and validates boolean inputs', function (): void { +it('guards guild discovery and preferences with the guilds flag and validates boolean inputs', function (): void { + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, true); $guild = Guild::factory()->create(); $this->get(route('guild.index'))->assertRedirectToRoute('home'); $this->putJson(route('guild-membership.update', $guild), ['joined' => true])->assertUnauthorized(); @@ -1083,7 +1098,7 @@ Storage::assertMissing('guild-icons/pending.webp'); })->with(['removed moderator' => true, 'claimed by someone else' => false]); -it('leaves reviewing guild submissions to admins with the preview', function (bool $disabled): void { +it('leaves reviewing guild submissions to admins while guilds are on', function (bool $disabled): void { Storage::fake(); $admin = User::factory()->create(['handle' => 'admin']); $user = $disabled ? $admin : User::factory()->create(['handle' => 'ordinary']); diff --git a/tests/Feature/Controllers/GuildMembershipControllerTest.php b/tests/Feature/Controllers/GuildMembershipControllerTest.php index c9769adb1..01a428f48 100644 --- a/tests/Feature/Controllers/GuildMembershipControllerTest.php +++ b/tests/Feature/Controllers/GuildMembershipControllerTest.php @@ -2,8 +2,10 @@ declare(strict_types=1); +use App\Enums\Feature; use App\Models\Guild; use App\Models\User; +use App\Services\Features; beforeEach(function (): void { config(['app.admins' => ['admin']]); @@ -57,10 +59,13 @@ ->assertOk()->assertInertia(fn ($page) => $page->has('users.data', 1)->where('users.data.0.id', $viewer->id)->where('users.data.0.is_moderator', false)); }); -it('requires sign in and the guild preview feature to list members', function (): void { +it('requires sign in and guild access to list members', function (): void { $guild = Guild::factory()->create(); $this->get(route('guild-membership.index', $guild->handle))->assertRedirectToRoute('home'); + + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, adminOnly: true); $this->actingAs(User::factory()->create())->get(route('guild-membership.index', $guild->handle))->assertNotFound(); }); diff --git a/tests/Feature/Controllers/GuildReadControllerTest.php b/tests/Feature/Controllers/GuildReadControllerTest.php index a68bbcd64..ada152f82 100644 --- a/tests/Feature/Controllers/GuildReadControllerTest.php +++ b/tests/Feature/Controllers/GuildReadControllerTest.php @@ -3,12 +3,14 @@ declare(strict_types=1); use App\Enums\CommitStatus; +use App\Enums\Feature; use App\Enums\UserUpdate; use App\Events\UsersUpdated; use App\Models\Commit; use App\Models\Guild; use App\Models\User; use App\Queries\JoinedGuildsQuery; +use App\Services\Features; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Event; use Inertia\Testing\AssertableInertia; @@ -117,6 +119,9 @@ function joinGuild(User $user, Guild $guild, string $joinedAt, ?string $readAt = it('hides the endpoint without the guilds feature, from guests, and for a missing guild', function (): void { $guild = Guild::factory()->create(); + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, true, adminOnly: true); + $this->actingAs($this->author)->put(route('guild-read.update', $guild->id))->assertNotFound(); $this->actingAs($this->reader)->put(route('guild-read.update', '019a0000-0000-7000-8000-000000000000'))->assertNotFound(); auth()->logout(); diff --git a/tests/Feature/Controllers/UserControllerTest.php b/tests/Feature/Controllers/UserControllerTest.php index b4d231240..d6039944d 100644 --- a/tests/Feature/Controllers/UserControllerTest.php +++ b/tests/Feature/Controllers/UserControllerTest.php @@ -108,7 +108,9 @@ it('does not expose profile guild memberships without access to guilds', function (?string $viewerHandle, bool $enabled): void { config(['app.admins' => ['admin']]); - resolve(Features::class)->update(Feature::Guilds, $enabled); + + // Guilds default to everyone; make them admin-only to check that setting still keeps members out. + resolve(Features::class)->update(Feature::Guilds, $enabled, true); $user = User::factory()->create(); Guild::factory()->create()->members()->attach($user, ['joined_at' => now()]); @@ -122,7 +124,7 @@ ->where('profileGuilds', null)); })->with([ 'guest' => [null, true], - 'outside preview' => ['member', true], + 'admins only' => ['member', true], 'disabled' => ['admin', false], ]); diff --git a/tests/Unit/OrgMentionSuggestions.test.tsx b/tests/Unit/OrgMentionSuggestions.test.tsx index bb416a5d1..5de1ce732 100644 --- a/tests/Unit/OrgMentionSuggestions.test.tsx +++ b/tests/Unit/OrgMentionSuggestions.test.tsx @@ -155,7 +155,7 @@ test('fetches matching guilds on demand and inserts a hex-shaped hashtag', async cleanup(); }); -test('does not suggest guilds inside code, URLs, partial handles or when preview data is absent', () => { +test('does not suggest guilds inside code, URLs, partial handles or when guild data is absent', () => { for (const value of [ '`#rust', '```\n#rust', diff --git a/tests/Unit/Queries/LogQueries/FollowingLogQueryTest.php b/tests/Unit/Queries/LogQueries/FollowingLogQueryTest.php index f04885609..d0a32140a 100644 --- a/tests/Unit/Queries/LogQueries/FollowingLogQueryTest.php +++ b/tests/Unit/Queries/LogQueries/FollowingLogQueryTest.php @@ -71,7 +71,8 @@ $builder = resolve(FollowingLogQuery::class)->builder($user); - expect(DB::getQueryLog())->toBeEmpty() + // Joined guilds may be looked up early; followed users must not be. + expect(collect(DB::getQueryLog())->pluck('query')->filter(fn (string $query): bool => str_contains($query, '"follows"')))->toBeEmpty() ->and($builder->toSql())->toContain('select "followed_id" from "follows"'); }); diff --git a/tests/Unit/ThreadRecovery.test.tsx b/tests/Unit/ThreadRecovery.test.tsx index 178fbca8b..9e8bfde0e 100644 --- a/tests/Unit/ThreadRecovery.test.tsx +++ b/tests/Unit/ThreadRecovery.test.tsx @@ -116,7 +116,7 @@ function Previews() { } for (const preview of [false, true]) { - test(`log previews defer relationship recovery to their log (guild preview ${preview})`, async () => { + test(`log previews defer relationship recovery to their log (guilds available ${preview})`, async () => { component = 'log/show'; guildPreview = preview; server = ['r1', 'r2'];