Skip to content
Open
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
6 changes: 4 additions & 2 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@ The **Commits** tab lists the organization's own commits, newest first. The **Me

While nobody has claimed an organization's page, it says so to signed-in visitors, with a **Claim** button. A member of the organization can **Claim** its page, which lists them as its admin. Only the first member to claim it becomes its admin: once a page has one, it can't be claimed again, and the Claim button is gone. Claiming asks for no extra GitHub permission: it checks that GitHub lists you among the organization's public members. GitHub keeps membership private by default, so if yours is, the page links to the organization's People page on GitHub, where you make your membership public, then claim again. You can make it private again once you're the admin. GitHub is only the way in: leaving the organization on GitHub doesn't remove you as an admin on /dev/null.

After that, members are managed on /dev/null, not mirrored from GitHub. An organization's members open its **Settings** from its page, where the **Members** tab lists everyone, each an **admin** or a **member**. Admins add people by their /dev/null handle, searching by handle or name as they type, except people they blocked or who blocked them, make them admins or members, and remove them. Any member can leave. Its last admin can't leave or become a member. Only its members see who its members are; its page lists its admins to everyone. Your organizations and your role in each are in your data export and go when you delete your account.
After that, members are managed on /dev/null, not mirrored from GitHub. An organization's members open its **Settings** from its page, where the **Members** tab lists everyone, each an **admin** or a **member**. Admins add people by their /dev/null handle, searching by handle or name as they type, except people they blocked or who blocked them, make them admins or members, and remove them. Any member can leave. Its last admin can't leave or become a member. Its page lists its admins to everyone. Only its members see who all its members are, until its admins show its **People**. Your organizations and your role in each are in your data export and go when you delete your account.

Its admins and members can **post as the organization**: in the composer, in a reply's and in the quote dialog, they open their avatar and pick the organization, then switch back to themselves the same way. Every commit, reply and quote starts as yourself. A commit from an organization shows the organization alone, with its square avatar and color, at `/@{handle}/commits/{id}`: nobody else sees which member posted it. It belongs to the organization: any of its members can delete it, and none can star it, report it, vote in its poll or give it pastéis. It counts toward no one's level, and blocking or muting the person who posted it doesn't hide it. Moderators see the person who posted it, in the review queue and in reports, and can time out or ban them from their profile. If they delete their account, the organization's commits they posted stay. Its admins and members hear about the organization in their own notifications, all except whoever did it: replies to its commits, quotes of them, stars on them and commits that mention it, said as the organization's, like **replied to @laravel's commit** or **mentioned @laravel**. They all see the organization's pending and rejected commits, like whoever posted them, and all hear when one is rejected, with the reason. Someone removed from the organization keeps what they already heard and hears nothing new, and no longer sees its rejected commits or what they heard about them. They can schedule commits as the organization too, the same way: if they are no longer a member when it is due, it is canceled. When the organization replies, quotes or mentions someone, they hear it from the organization, never from whoever posted it, so blocking or muting that person doesn't silence it; its members hear nothing of what it does to its own commits or mentioning itself. Its first commit isn't announced to its followers, as a person's is. Apps can post as an organization through the API too, by sending its handle as `author`.

Every organization has a color, /dev/null's blue until an admin chooses another in the **Profile** tab of its **Settings**, where its admins land: one of the same six lane colors as developers, or a custom one. It rings the organization's avatar, leads its handle, and colors its link preview.

The same tab has **People**, hidden until an admin shows it. Shown, the organization's page gets a **People** tab listing its admins and members, first joined first, to everyone, guests included, with a Follow button beside each for signed-in visitors. People across a block with you, or whom you muted, are left out. Hiding it again takes the tab away; the members stay members.

Signed in, you can **Follow** an organization from its page, which shows how many people follow it. Once you follow it, the button opens a menu where you can unfollow. Following puts the organization's own commits in your Following log, and ranks them higher in Trending, like the people you follow. **Watch**, which will also show the commits that mention the organization, is planned and shown as coming soon. The organizations you follow are listed on your Following list, above the people, a few at a time with **Show more organizations**, and count toward your following count. They are in your data export and go when you delete your account.

Sources: [organization page](resources/js/pages/organization/show.tsx), [commits](app/Queries/OrganizationCommitsQuery.php), [posting as an organization](app/Rules/OrganizationToPostAs.php), [mentions](app/Queries/OrganizationMentionsQuery.php), [organization lookups](app/Actions/UpdateCommitTopics.php), [claims](app/Http/Controllers/OrganizationAdminController.php), [color](app/Http/Controllers/OrganizationLaneController.php), [members](app/Http/Controllers/OrganizationMemberController.php).
Sources: [organization page](resources/js/pages/organization/show.tsx), [commits](app/Queries/OrganizationCommitsQuery.php), [posting as an organization](app/Rules/OrganizationToPostAs.php), [mentions](app/Queries/OrganizationMentionsQuery.php), [organization lookups](app/Actions/UpdateCommitTopics.php), [claims](app/Http/Controllers/OrganizationAdminController.php), [color](app/Http/Controllers/OrganizationLaneController.php), [members](app/Http/Controllers/OrganizationMemberController.php), [people](app/Queries/OrganizationPeopleQuery.php), [showing people](app/Http/Controllers/OrganizationPeopleVisibilityController.php).

### Developers not on /dev/null yet

Expand Down
18 changes: 18 additions & 0 deletions app/Actions/UpdateOrganizationPeopleVisibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Actions;

use App\Events\ProfilesUpdated;
use App\Models\Organization;

final readonly class UpdateOrganizationPeopleVisibility
{
public function handle(Organization $organization, bool $showsPeople): void
{
$organization->update(['shows_people' => $showsPeople]);

event(new ProfilesUpdated([$organization->id]));
}
}
32 changes: 24 additions & 8 deletions app/Http/Controllers/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
use App\Models\User;
use App\Queries\OrganizationCommitsQuery;
use App\Queries\OrganizationMentionsQuery;
use App\Queries\OrganizationPeopleQuery;
use App\Services\PageMetadata;
use Closure;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Contracts\Pagination\CursorPaginator as CursorPage;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\RedirectResponse;
use Illuminate\Pagination\CursorPaginator;
Expand All @@ -28,11 +30,12 @@
{
/**
* Organization pages are public, at the "@handle" of users, and show the organization's GitHub profile, its own
* commits and the commits that mention it, in the lane its admins chose or /dev/null's blue, with its admins, first one first, how
* many follow it and whether the viewer does, and the organization's link preview, and its members the way to its
* settings. Like users' pages, they move for good to the handle's own case.
* commits and the commits that mention it, and its members once its admins show them, in the lane its admins chose
* or /dev/null's blue, with its admins, first one first, how many follow it and whether the viewer does, and the
* organization's link preview, and its members the way to its settings. Like users' pages, they move for good to
* the handle's own case.
*/
public function show(ShowOrganizationRequest $request, #[CurrentUser] ?User $currentUser, OrganizationCommitsQuery $organizationCommits, OrganizationMentionsQuery $mentions, PageMetadata $metadata): RedirectResponse|Response
public function show(ShowOrganizationRequest $request, #[CurrentUser] ?User $currentUser, OrganizationCommitsQuery $organizationCommits, OrganizationMentionsQuery $mentions, OrganizationPeopleQuery $people, PageMetadata $metadata): RedirectResponse|Response
{
$organization = $request->organization();
assert($organization instanceof Organization);
Expand All @@ -44,17 +47,30 @@ public function show(ShowOrganizationRequest $request, #[CurrentUser] ?User $cur
return redirect(route('user.show', $organization->handle).($query === '' ? '' : "?{$query}"), 301, ['Cache-Control' => 'max-age=86400, private']);
}

// Resolved once, so a refresh of the organization while the props resolve can't make the tab and its stream disagree.
$tab = $request->tab();

// A link to the next page of people its admins have since hidden carries a cursor the commits can't read...
if ($request->filled('cursor') && $request->string('tab')->value() === 'people' && $tab !== 'people') {
return redirect()->route('user.show', $organization->handle);
}

// What its page shows about the organization changes for everyone on its public channel, and what it shows
// about the viewer's own relationship to it on theirs.
$profile = new Channel('profiles.'.$organization->id);
$relationship = fn (Closure $value): Closure|LiveProp => $currentUser instanceof User ? Inertia::live($value, UserUpdate::Account->value, new PrivateChannel($currentUser)) : $value;

return Inertia::render('organization/show', [
'organization' => Inertia::live(fn (): Organization => $organization->refresh(), 'profile', $profile),
'tab' => $request->tab(...),
'commits' => Inertia::scroll(fn (): CursorPaginator => ShownStreams::page(($request->tab() === 'mentions' ? $mentions : $organizationCommits)->builder($organization, $currentUser)
->cursorPaginate(20)
->appends(['tab' => $request->tab()]))),
'tab' => $tab,
...$tab === 'people' ? [
'people' => Inertia::scroll(fn (): CursorPage => $people->page($organization, $currentUser)),
] : [
'commits' => Inertia::scroll(fn (): CursorPaginator => ShownStreams::page(($tab === 'mentions' ? $mentions : $organizationCommits)->builder($organization, $currentUser)
->cursorPaginate(20)
->appends(['tab' => $tab]))),
],
'showsPeople' => Inertia::live(fn (): bool => $organization->refresh()->shows_people, 'profile', $profile),
'claimUrl' => route('organization-admin.store', $organization),
// Admins land on the Profile tab, which only they have...
'settingsUrl' => $relationship(fn (): ?string => match ($currentUser instanceof User ? $organization->roleOf($currentUser) : null) {
Expand Down
32 changes: 32 additions & 0 deletions app/Http/Controllers/OrganizationPeopleVisibilityController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Actions\UpdateOrganizationPeopleVisibility;
use App\Http\Requests\UpdateOrganizationPeopleVisibilityRequest;
use App\Models\Organization;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;

/**
* Whether an organization's page shows its members to everyone, in the Profile tab of its settings. Only its admins
* choose it.
*/
final readonly class OrganizationPeopleVisibilityController
{
public function update(UpdateOrganizationPeopleVisibilityRequest $request, Organization $organization, UpdateOrganizationPeopleVisibility $action): RedirectResponse
{
$showsPeople = $request->showsPeople();

$action->handle($organization, $showsPeople);

Inertia::flash('toast', [
'type' => 'success',
'message' => $showsPeople ? 'People are shown on the page.' : 'People are hidden from the page.',
]);

return back();
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/OrganizationProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use Inertia\Response;

/**
* The Profile tab of an organization's settings, like the user's, where its admins choose its color.
* The Profile tab of an organization's settings, like the user's, where its admins choose its color and whether its
* page shows its people.
*/
final readonly class OrganizationProfileController
{
Expand All @@ -20,6 +21,7 @@ public function edit(ShowOrganizationProfileRequest $request, Organization $orga
return Inertia::render('organization-profile/edit', [
'organization' => $organization,
'role' => OrganizationRole::Admin,
'showsPeople' => $organization->shows_people,
]);
}
}
10 changes: 7 additions & 3 deletions app/Http/Requests/ShowOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ public function authorize(): Response
public function rules(): array
{
return [
'tab' => ['nullable', 'string', 'in:commits,mentions'],
'tab' => ['nullable', 'string', 'in:commits,mentions,people'],
];
}

/**
* The organization's own commits first, then the commits that mention it.
* The organization's own commits first, then the commits that mention it, then its people when its admins show them.
*/
public function tab(): string
{
return $this->string('tab')->value() === 'mentions' ? 'mentions' : 'commits';
return match ($this->string('tab')->value()) {
'mentions' => 'mentions',
'people' => $this->organization()?->shows_people === true ? 'people' : 'commits',
Comment thread
danielh-official marked this conversation as resolved.
Resolved
default => 'commits',
};
}

/**
Expand Down
42 changes: 42 additions & 0 deletions app/Http/Requests/UpdateOrganizationPeopleVisibilityRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace App\Http\Requests;

use App\Models\Organization;
use App\Models\User;
use Illuminate\Auth\Access\Response;
use Illuminate\Foundation\Http\FormRequest;

final class UpdateOrganizationPeopleVisibilityRequest extends FormRequest
{
/**
* Only the organization's admins choose who sees its members, so to everyone else it looks like it does not exist.
*/
public function authorize(): Response
{
$user = $this->user();
assert($user instanceof User);

$organization = $this->route('organization');
assert($organization instanceof Organization);

return $organization->isAdmin($user) ? Response::allow() : Response::denyAsNotFound();
}

/**
* @return array<string, array<int, string>>
*/
public function rules(): array
{
return [
'shows_people' => ['required', 'boolean'],
];
}

public function showsPeople(): bool
{
return $this->boolean('shows_people');
}
}
2 changes: 2 additions & 0 deletions app/Models/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @property-read CarbonInterface|null $github_synced_at
* @property-read int|null $preferred_lane
* @property-read string|null $lane_color
* @property-read bool $shows_people
* @property-read CarbonInterface $created_at
* @property-read CarbonInterface $updated_at
* @property-read Profile $profile
Expand Down Expand Up @@ -69,6 +70,7 @@ public function casts(): array
'id' => 'string',
'preferred_lane' => 'integer',
'lane_color' => 'string',
'shows_people' => 'boolean',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
Expand Down
59 changes: 59 additions & 0 deletions app/Queries/OrganizationPeopleQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

namespace App\Queries;

use App\Models\Organization;
use App\Models\User;
use Illuminate\Contracts\Pagination\CursorPaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\Pivot;

final readonly class OrganizationPeopleQuery
{
/**
* The organization's members, on the People tab of its page, first joined first, as the viewer, or a guest, may see
* them: without anyone across a block or muted, and with whether the viewer follows each one and each one follows
* them.
*
* @return BelongsToMany<User, Organization>
*/
public function builder(Organization $organization, ?User $viewer): BelongsToMany
{
$people = $organization->members()
->oldest('organization_members.created_at')
->oldest('users.id');

if (! $viewer instanceof User) {
return $people;
}

return $people
->whereNotIn('users.id', $viewer->idsAcrossBlocks())
->whereNotIn('users.id', $viewer->mutedIds())
->withExists([
'followers as is_followed' => fn (Builder $query): Builder => $query->whereKey($viewer->id),
'following as follows_you' => fn (Builder $query): Builder => $query->whereKey($viewer->id),
]);
}

/**
* A page of them, without the roles and join dates of the membership: the page lists its admins already.
*
* @return CursorPaginator<int, User&object{pivot: Pivot}>
*/
public function page(Organization $organization, ?User $viewer): CursorPaginator
{
$people = $this->builder($organization, $viewer)
->cursorPaginate(30)
->appends(['tab' => 'people']);

foreach ($people->items() as $person) {
$person->makeHidden('pivot');
}

return $people;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Whether everyone sees the organization's members on a People tab of its page. Only its members see them until its
* admins switch it on.
*/
public function up(): void
{
Schema::table('organizations', function (Blueprint $table): void {
$table->boolean('shows_people')->default(false);
});
}
};
8 changes: 5 additions & 3 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ public function run(): void
}

/**
* Two GitHub organizations, as if someone had mentioned them: /dev/null, which the local developer manages, and
* Laravel, which they follow. Their pages list threads that mention them, and the commits they post, through their
* members, reach the Following log of whoever follows them.
* Two GitHub organizations, as if someone had mentioned them: /dev/null, which the local developer manages and whose
* page shows its people, and Laravel, which they follow and whose page keeps them hidden. Their pages list threads
* that mention them, and the commits they post, through their members, reach the Following log of whoever follows
* them.
*
* @param Collection<int, User> $users
*/
Expand All @@ -98,6 +99,7 @@ private function seedOrganizations(User $localDeveloper, Collection $users): voi
$localDeveloper->id => ['role' => OrganizationRole::Admin],
...array_fill_keys([$maintainer->id, $contributor->id, $reviewer->id], ['role' => OrganizationRole::Member]),
]);
$devNull->update(['shows_people' => true]);
$devNull->followers()->syncWithoutDetaching($users->take(5)->modelKeys());
$laravel->admins()->syncWithoutDetaching([$artisan->id]);
$laravel->followers()->syncWithoutDetaching([$localDeveloper->id, $maintainer->id]);
Expand Down
Loading