Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ Sources: [issue command UI](resources/js/components/issue-command.tsx), [issue v

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 icon and description. 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; a guild that the moderation flags is not saved.

The Guilds page lists groups by member count. 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.
The Guilds page lists groups by member count. 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.

Each guild's bulletin board shows commits posted directly to it and regular commits containing its exact hashtag—not semantic search. Matching replies bring their thread onto the board, even when the root has no hashtag. Threads show reply previews and expand like a regular commit log, ordered by root date, newest first. Each page contains 30 distinct root commits; replies do not use up that limit, and Load more adds the next page. Posts from the board's composer stay attached to that guild without an automatic hashtag, including scheduled posts. They count toward the author's commit count but do not appear in their profile log or general feeds. They appear in Following when you join the guild, and in semantic search suggestions and results under a divider with the guild's name and icon. Regular hashtag commits keep appearing on profiles and in feeds as usual. Typing a hashtag offers matching guilds in the autocomplete menu; select one with the keyboard or pointer to insert its handle.

Expand Down
22 changes: 22 additions & 0 deletions app/Http/Controllers/GuildMembershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,36 @@
namespace App\Http\Controllers;

use App\Actions\UpdateGuildMembership;
use App\Http\Requests\ListGuildMembersRequest;
use App\Http\Requests\UpdateGuildMembershipRequest;
use App\Models\Guild;
use App\Models\User;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;

final readonly class GuildMembershipController
{
public function index(ListGuildMembersRequest $request, Guild $guild): Response
{
return Inertia::render('guild/members', [
'guild' => $guild,
'users' => Inertia::scroll(fn () => $guild->members()
->orderByRaw('(users.id = ?) desc nulls last', [$guild->user_id])
->orderByPivot('joined_at', 'desc')->latest('users.id')
->paginate(50)->through(fn (User $member): array => [

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh. ship it

'id' => $member->id,
'handle' => $member->handle,
'name' => $member->name,
'avatar_url' => $member->avatar_url,
'bio' => $member->bio,
'lane' => $member->lane(),
'is_moderator' => $member->id === $guild->user_id,
])),
])->withViewData(['robots' => 'noindex, follow']);
}

public function update(UpdateGuildMembershipRequest $request, Guild $guild, #[CurrentUser] User $user, UpdateGuildMembership $action): RedirectResponse
{
$action->handle($user, $guild, $request->boolean('joined'));
Expand Down
24 changes: 24 additions & 0 deletions app/Http/Requests/ListGuildMembersRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Http\Requests;

use App\Enums\Feature;
use App\Services\Features;
use Illuminate\Auth\Access\Response;
use Illuminate\Foundation\Http\FormRequest;

final class ListGuildMembersRequest extends FormRequest
{
public function authorize(Features $features): Response
{
return $features->available(Feature::Guilds, $this->user()) ? Response::allow() : Response::denyAsNotFound();
}

/** @return array<string, list<string>> */
public function rules(): array
{
return ['page' => ['sometimes', 'integer', 'min:1']];
}
}
15 changes: 10 additions & 5 deletions resources/js/components/guild-preferences.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { router } from '@inertiajs/react';
import { Link, router } from '@inertiajs/react';
import { UserPlus, Volume2, VolumeX } from 'lucide-react';
import { useState } from 'react';
import { update as membership } from '@/actions/App/Http/Controllers/GuildMembershipController';
import {
index as members,
update as membership,
} from '@/actions/App/Http/Controllers/GuildMembershipController';
import { update as mute } from '@/actions/App/Http/Controllers/GuildMuteController';
import { useFollowHover } from '@/components/follow-button';
import { Button } from '@/components/ui/button';
Expand All @@ -10,8 +13,10 @@ import type { Guild } from '@/types/guild';

export function GuildMemberCount({ guild }: { guild: Guild }) {
return (
<span
className="inline-block w-[15ch] shrink-0 text-sm text-muted-foreground"
<Link
href={members(guild.handle)}
prefetch
className="inline-block w-[15ch] shrink-0 text-sm text-muted-foreground hover:text-foreground hover:underline focus-visible:underline"
title={`${formatExactCount(guild.member_count)} members`}
>
<span className="mr-1 font-mono tabular-nums" aria-hidden="true">
Expand All @@ -21,7 +26,7 @@ export function GuildMemberCount({ guild }: { guild: Guild }) {
{formatExactCount(guild.member_count)}{' '}
</span>
{guild.member_count === 1 ? 'member' : 'members'}
</span>
</Link>
);
}

Expand Down
133 changes: 133 additions & 0 deletions resources/js/pages/guild/members.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { Head, InfiniteScroll, Link } from '@inertiajs/react';
import { ArrowLeft } from 'lucide-react';
import type { CSSProperties } from 'react';
import { show } from '@/actions/App/Http/Controllers/GuildController';
import { EmptyFeed } from '@/components/commit-feed';
import { Button } from '@/components/ui/button';
import { Spinner } from '@/components/ui/spinner';
import { UserAvatar } from '@/components/user-avatar';
import AppLayout from '@/layouts/app-layout';
import { laneColor } from '@/lib/utils';
import { show as profile } from '@/routes/user';
import type { User } from '@/types';
import type { Guild } from '@/types/guild';

export default function Members({
guild,
users,
}: {
guild: Pick<Guild, 'handle' | 'name'>;
users: {
data: (Pick<
User,
'id' | 'handle' | 'name' | 'avatar_url' | 'bio' | 'lane'
> & { is_moderator: boolean })[];
};
}) {
return (
<>
<Head title={`Members · ${guild.name}`} />
<header className="sticky top-0 z-10 flex h-14 items-center gap-3 border-b bg-card px-4 sm:px-6">
<Link
href={show(guild.handle)}
prefetch
aria-label={`Back to ${guild.name}`}
className="text-muted-foreground hover:text-foreground"
>
<ArrowLeft className="size-4" />
</Link>
<h1
className="min-w-0 truncate font-semibold"
title={guild.name}
>
{guild.name}
</h1>
<p className="shrink-0 text-sm text-muted-foreground">
Members
</p>
</header>
{users.data.length === 0 ? (
<div className="px-6 py-16 text-center sm:px-12">
<EmptyFeed command="fatal: no members yet">
Nobody has joined this guild yet.
</EmptyFeed>
</div>
) : (
<InfiniteScroll
data="users"
manual
onlyNext
preserveUrl
next={({ hasMore, loading, fetch }) =>
hasMore && (
<div className="flex justify-center py-4">
<Button
variant="outline"
onClick={fetch}
disabled={loading}
>
<Spinner
className={loading ? '' : 'invisible'}
/>
Load more
</Button>
</div>
)
}
>
<ul className="divide-y">
{users.data.map((person) => (
<li key={person.id}>
<Link
href={profile(person)}
prefetch
className="flex min-w-0 items-start gap-3 px-4 py-3 hover:bg-muted/50 sm:px-6"
>
<UserAvatar
user={person}
className="size-10 shrink-0 ring-2 ring-(--lane) ring-offset-2 ring-offset-card"
style={
{
'--lane': laneColor(
person.lane,
),
} as CSSProperties
}
/>
<div className="min-w-0">
<div className="flex min-w-0 items-baseline gap-1">
<p
className="truncate font-medium"
title={person.name}
>
{person.name}
</p>
{person.is_moderator && (
<span className="shrink-0 text-sm text-muted-foreground">
(moderator)
</span>
)}
</div>
<p
className="truncate font-mono text-sm text-muted-foreground"
title={`@${person.handle}`}
>
@{person.handle}
</p>
{person.bio && (
<p className="mt-1 line-clamp-2 text-sm wrap-anywhere">
{person.bio}
</p>
)}
</div>
</Link>
</li>
))}
</ul>
</InfiniteScroll>
)}
</>
);
}

Members.layout = AppLayout;
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
Route::middleware('auth')->group(function (): void {
Route::get('guilds', [GuildController::class, 'index'])->name('guild.index');
Route::get('guilds/{guild:handle}', [GuildController::class, 'show'])->name('guild.show');
Route::get('guilds/{guild:handle}/members', [GuildMembershipController::class, 'index'])->name('guild-membership.index');
Route::get('guilds/{guild:handle}/icon', [GuildIconController::class, 'show'])->name('guild-icon.show');
Route::post('guilds', [GuildController::class, 'store'])->middleware([PreventPostingInTimeout::class, 'throttle:10,1'])->name('guild.store');
Route::put('guilds/{guild:handle}', [GuildController::class, 'update'])->middleware([PreventPostingInTimeout::class, 'throttle:10,1'])->name('guild.update');
Expand Down
73 changes: 73 additions & 0 deletions tests/Feature/Controllers/GuildMembershipControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

declare(strict_types=1);

use App\Models\Guild;
use App\Models\User;

beforeEach(function (): void {
config(['app.admins' => ['admin']]);
});

it('lists the moderator first then joined members newest first in pages of fifty without private preferences', function (): void {
$viewer = User::factory()->create(['handle' => 'admin']);
$moderator = User::factory()->create();
$guild = Guild::factory()->create(['user_id' => $moderator->id]);
$older = User::factory()->create();
$members = User::factory()->count(50)->create();
$guild->members()->attach($moderator, ['joined_at' => now()->subDays(2)]);
$guild->members()->attach($older, ['joined_at' => now()->subDay()]);
$guild->members()->attach($members->modelKeys(), ['joined_at' => now()]);
$guild->muters()->attach(User::factory()->create(), ['muted_at' => now()]);
Guild::factory()->create()->members()->attach(User::factory()->create(), ['joined_at' => now()]);

$this->actingAs($viewer)->get(route('guild-membership.index', $guild->handle))
->assertOk()->assertInertia(fn ($page) => $page
->component('guild/members')
->where('guild.handle', $guild->handle)
->has('users.data', 50)
->where('users.data.0.id', $moderator->id)
->where('users.data.0.is_moderator', true)
->where('users.data.1.is_moderator', false)
->where('users.data', fn ($users): bool => collect($users)->pluck('id')->all() === [$moderator->id, ...$members->sortByDesc('id')->take(49)->values()->modelKeys()])
->where('users.current_page', 1)
->where('users.per_page', 50)
->where('users.next_page_url', route('guild-membership.index', ['guild' => $guild->handle, 'page' => 2]))
->missing('users.data.0.email')
->missing('users.data.0.pivot'));

$this->get(route('guild-membership.index', ['guild' => $guild->handle, 'page' => 2]))
->assertOk()->assertInertia(fn ($page) => $page
->has('users.data', 2)
->where('users.data.0.id', $members->sortBy('id')->first()->id)
->where('users.data.1.id', $older->id)
->where('users.next_page_url', null));
});

it('keeps paused guild members accessible and supports an empty list', function (): void {
$viewer = User::factory()->create(['handle' => 'admin']);
$guild = Guild::factory()->create(['user_id' => null]);

$this->actingAs($viewer)->get(route('guild-membership.index', $guild->handle))
->assertOk()->assertInertia(fn ($page) => $page->has('users.data', 0)->where('users.next_page_url', null));

$guild->members()->attach($viewer, ['joined_at' => now()]);

$this->get(route('guild-membership.index', $guild->handle))
->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 {
$guild = Guild::factory()->create();

$this->get(route('guild-membership.index', $guild->handle))->assertRedirectToRoute('home');
$this->actingAs(User::factory()->create())->get(route('guild-membership.index', $guild->handle))->assertNotFound();
});

it('rejects invalid member pages', function (mixed $page): void {
$guild = Guild::factory()->create();

$this->actingAs(User::factory()->create(['handle' => 'admin']))
->getJson(route('guild-membership.index', ['guild' => $guild->handle, 'page' => $page]))
->assertUnprocessable()->assertJsonValidationErrors('page');
})->with([0, 'not-a-page']);
Loading