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
10 changes: 6 additions & 4 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ A signed request sees what the web shows you, such as your own pending commits a
- follow or unfollow people and organizations, mute or unmute, and block or unblock, and list who you muted and blocked;
- read who to follow, also as it is suggested beside a profile or a commit, and mark a suggestion not interested;
- read the hot topics, and each one's commits from the past week with its recap;
- list guilds as the Guilds page does, 24 a page, searched by name, handle or description, with whether you joined or muted each one and whether it is paused, while guilds are available to you;
- read a guild's board as its page does, 30 threads a page with reply previews, with the guild, its pinned commit and whether you moderate it, while guilds are available to you. The pinned commit also keeps its place in the list, so an app that shows it apart skips it there by its id;
- list guilds as the Guilds page does, 24 a page, searched by name, handle, alias or description, with each guild's aliases, whether you joined or muted each one and whether it is paused, while guilds are available to you;
- read a guild's board as its page does, by its handle or one of its aliases, 30 threads a page with reply previews, with the guild, its pinned commit and whether you moderate it, while guilds are available to you. The pinned commit also keeps its place in the list, so an app that shows it apart skips it there by its id;
- star or unstar, and list who starred your own commit, newest first, 20 a page;
- create polls on commits that are neither replies nor quotes, and vote on polls;
- change Remotes settings, read and send messages with images, link cards, and voice notes in conversations and orgs, mark them pulled, react to messages and list your reactions, pin and unpin org messages as a maintainer, find people, and start orgs;
Expand Down Expand Up @@ -652,14 +652,16 @@ 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 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.

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.
The Guilds page lists groups by member count, with 24 guilds per page. Search matches keywords in guild names, handles, aliases, 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.

The guilds you joined are listed in the left navigation, with the guilds that have the most commits you missed first. Guilds with the same number of missed commits are ordered by how much you have committed in them, counting your recent approved commits. The count of missed commits starts from your last visit to the guild's board, or from when you joined, and leaves out your own commits, commits you cannot see, and commits by people you muted. Counts above 99 show as 99+, and a muted guild is not listed. Opening a board clears its count, and a line marks where the commits that are new since your last visit end.

While guilds are available to you, profiles show a guild count beside following and followers. Click it to see the guilds that person has joined, listed by hashtag, with links to their boards. You can join or leave those guilds directly from the list. Muting a guild does not remove it from this membership list; leaving does.

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. Outside the board, such as when one is opened by its link, a board post names the guild it was posted in and notes that it is not shown in general logs. 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.

A guild's moderator can add aliases from its page: other hashtags that lead to the same guild. With `#golang` as an alias of `#go`, both hashtags show the guild's label, commits containing either appear on its board and count for joining, muting and missed commits, and `/guilds/golang` opens the same guild. An alias follows the rules of a handle: it starts with a letter, contains only letters, numbers and underscores, and allows up to 60 characters. It must be a free hashtag: one that is already a guild, including a paused guild, or already an alias of any guild cannot be used, and nobody can create a guild for a hashtag that is an alias. Each guild can have up to 10 aliases, and each passes the same automated moderation as commits; one that is flagged is refused. Aliases are listed beside the hashtag on the guild's page, the hashtag autocomplete finds a guild by an alias and inserts its handle, and the directory search matches them. The moderator can remove an alias at any time, which takes commits that only carry that hashtag off the board. Aliases stay with a paused guild.

The guild's moderator can pin one commit from its board, including a thread brought in by a matching reply. It appears first with a “Pinned to board” label, without appearing twice or changing profile pins or other guilds. The pin is separate from the 30 chronological threads per page, so pinning never changes what Load more brings in. Pinning another replaces it; unpinning restores its natural position if already loaded, or removes its promotion until you load that older page. A pin never overrides visibility, blocks or author mutes, and disappears from the board if the thread no longer matches the guild. Permanently deleting the pinned commit clears the pin.

Guild descriptions can be reported privately. When a guild has no moderator, including after its moderator deletes their account, it is paused, not deleted. Its page, posts, icon, description, memberships and mute preferences stay connected. New board posts wait until it has a moderator; scheduled board posts stay pending and keep their guild, and committing one now says the guild is paused. Ordinary hashtag commits still appear. A different person can claim the hashtag to resume the same guild, but a removed moderator cannot reclaim it.
Expand All @@ -672,7 +674,7 @@ Choose **Download JSON** in Settings → Profile to export your account data. Th
- the days you used /dev/null (dates, not times), oldest first, with which of its apps you used on each (days before apps were tracked say web, whatever you used, and a phone approved before the mobile app started identifying itself says other), and the last of them;
- your commits and replies (including pending, rejected, and deleted entries still stored), their cached translations, polls, and your votes;
- stars, followers and people you follow, mutes, blocks, and dismissed **Not interested** suggestions;
- guilds you moderate, guilds and guild edits you submitted that are waiting for review, your guild memberships and mutes, reports you submitted, and guild moderator-removal records relating to your account;
- guilds you moderate with their aliases, guilds and guild edits you submitted that are waiting for review, your guild memberships and mutes, reports you submitted, and guild moderator-removal records relating to your account;
- messages you sent, including links to your voice notes, and notifications;
- SSH key fingerprints, approved devices, timeout history, and ban history;
- active-session metadata: IP address, browser information, and last activity.
Expand Down
3 changes: 2 additions & 1 deletion app/Actions/CreateExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ public function handle(User $user): array
'dismissed_suggestions' => $this->handles($user->dismissedSuggestions()),
'organizations' => $this->organizations($user),
'followed_organizations' => $this->followedOrganizations($user),
'guilds' => Guild::query()->where('user_id', $user->id)->orderBy('handle')->get()->map(fn (Guild $guild): array => [
'guilds' => Guild::query()->with('aliases')->where('user_id', $user->id)->orderBy('handle')->get()->map(fn (Guild $guild): array => [
...$guild->toArray(),
'aliases' => $guild->aliases->pluck('handle')->all(),
'icon' => $guild->icon_path === null ? null : route('guild-icon.show', $guild->handle),
'pinned_commit_id' => $guild->pinned_commit_id,
'created_at' => $guild->created_at->toIso8601String(),
Expand Down
11 changes: 10 additions & 1 deletion app/Actions/CreateGuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace App\Actions;

use App\Exceptions\GuildHandleTaken;
use App\Exceptions\GuildModeratorRemoved;
use App\Models\Guild;
use App\Models\GuildAlias;
use App\Models\GuildSubmission;
use App\Models\User;
use Illuminate\Http\UploadedFile;
Expand All @@ -19,7 +21,8 @@ public function __construct(private CreateImageFiles $images, private UpdateGuil
}

/**
* The icon is an upload, or the path of one already stored, such as a reviewed submission's.
* The icon is an upload, or the path of one already stored, such as a reviewed submission's. A hashtag that became
* another guild's alias meanwhile is taken.
*/
public function handle(User $user, string $handle, string $name, string $description, string $emoji, UploadedFile|string|null $icon, bool $flagged = false): Guild|GuildSubmission
{
Expand All @@ -30,6 +33,12 @@ public function handle(User $user, string $handle, string $name, string $descrip
throw new GuildModeratorRemoved;
}

DB::select('select pg_advisory_xact_lock(hashtextextended(?, 0))', [CreateGuildAlias::HANDLE_LOCK.mb_strtolower($handle)]);

if (GuildAlias::query()->where('handle', mb_strtolower($handle))->exists()) {
throw new GuildHandleTaken;
}

if ($flagged) {
assert($icon instanceof UploadedFile || $icon === null);

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

declare(strict_types=1);

namespace App\Actions;

use App\Enums\UserUpdate;
use App\Events\UsersUpdated;
use App\Models\Guild;
use App\Models\GuildAlias;
use App\Models\User;
use Illuminate\Support\Facades\DB;

final readonly class CreateGuildAlias
{
/**
* Held while a hashtag becomes a guild's handle or alias, so it never becomes both.
*/
public const string HANDLE_LOCK = 'guild-handle:';

/**
* The alias is checked again under the lock, and left out when its hashtag was taken meanwhile or the user no
* longer moderates the guild.
*
* The request checks the cap before this runs, but aliases added at the same moment each see the others missing.
* So the cap is counted again here, under the guild's lock: an alias past it is left out.
*/
public function handle(Guild $guild, User $user, string $handle): void
{
DB::transaction(function () use ($guild, $user, $handle): void {
DB::select('select pg_advisory_xact_lock(hashtextextended(?, 0))', [self::HANDLE_LOCK.$handle]);
$guild = Guild::query()->whereKey($guild->id)->lockForUpdate()->firstOrFail();

if ($guild->user_id !== $user->id || Guild::query()->where('handle', $handle)->exists() || GuildAlias::query()->where('handle', $handle)->exists()) {
return;
}

if ($guild->aliases()->count() >= GuildAlias::MAX_PER_GUILD) {
return;
}

$guild->aliases()->create(['handle' => $handle]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

event(new UsersUpdated(DB::table('guild_preferences')->where('guild_id', $guild->id)->pluck('user_id')->push($guild->user_id), UserUpdate::Guilds));
});
}
}
5 changes: 3 additions & 2 deletions app/Actions/CreateGuildSubmissionApproval.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Actions;

use App\Exceptions\GuildHandleTaken;
use App\Exceptions\GuildModeratorRemoved;
use App\Models\Guild;
use App\Models\GuildSubmission;
Expand All @@ -20,7 +21,7 @@ public function __construct(private CreateGuild $createGuild, private UpdateGuil
/**
* Publishes the submission as if it had passed the moderation: an edit when its author still moderates the guild,
* otherwise a new guild, which claims a paused one and leaves one someone else moderates alone. An author removed
* from the guild meanwhile gets nothing.
* from the guild meanwhile gets nothing, and neither does a hashtag that became another guild's alias.
*/
public function handle(?GuildSubmission $submission): void
{
Expand All @@ -43,7 +44,7 @@ public function handle(?GuildSubmission $submission): void
} else {
$this->createGuild->handle($submission->user, $submission->handle, $submission->name, $submission->description, $submission->emoji, $submission->icon_path);
}
} catch (GuildModeratorRemoved) {
} catch (GuildHandleTaken|GuildModeratorRemoved) {
//
}

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

declare(strict_types=1);

namespace App\Actions;

use App\Enums\UserUpdate;
use App\Events\UsersUpdated;
use App\Models\Guild;
use App\Models\GuildAlias;
use Illuminate\Support\Facades\DB;

final readonly class DeleteGuildAlias
{
public function handle(Guild $guild, GuildAlias $alias): void
{
$alias->delete();

event(new UsersUpdated(DB::table('guild_preferences')->where('guild_id', $guild->id)->pluck('user_id')->push($guild->user_id), UserUpdate::Guilds));
}
}
9 changes: 9 additions & 0 deletions app/Exceptions/GuildHandleTaken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace App\Exceptions;

use RuntimeException;

final class GuildHandleTaken extends RuntimeException {}
32 changes: 32 additions & 0 deletions app/Http/Controllers/GuildAliasController.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\CreateGuildAlias;
use App\Actions\DeleteGuildAlias;
use App\Http\Requests\CreateGuildAliasRequest;
use App\Http\Requests\DeleteGuildAliasRequest;
use App\Models\Guild;
use App\Models\GuildAlias;
use App\Models\User;
use Illuminate\Container\Attributes\CurrentUser;
use Illuminate\Http\RedirectResponse;

final readonly class GuildAliasController
{
public function store(CreateGuildAliasRequest $request, Guild $guild, #[CurrentUser] User $user, CreateGuildAlias $action): RedirectResponse
{
$action->handle($guild, $user, $request->string('handle')->value());

return to_route('guild.show', $guild->handle);
}

public function destroy(DeleteGuildAliasRequest $request, Guild $guild, GuildAlias $alias, DeleteGuildAlias $action): RedirectResponse
{
$action->handle($guild, $alias);

return to_route('guild.show', $guild->handle);
}
}
3 changes: 3 additions & 0 deletions app/Http/Controllers/GuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Actions\CreateGuild;
use App\Actions\UpdateGuild;
use App\Exceptions\GuildHandleTaken;
use App\Exceptions\GuildModeratorRemoved;
use App\Http\Requests\CreateGuildRequest;
use App\Http\Requests\ListGuildsRequest;
Expand Down Expand Up @@ -44,6 +45,8 @@ public function store(CreateGuildRequest $request, #[CurrentUser] User $user, Cr
$guild = $action->handle($user, $request->string('handle')->value(), $request->string('name')->value(), $request->string('description')->value(), $request->string('emoji')->value(), $icon, $request->isFlagged());
} catch (GuildModeratorRemoved) {
return back()->withErrors(['handle' => 'You cannot reclaim a guild you were removed from.']);
} catch (GuildHandleTaken) {
return back()->withErrors(['handle' => 'A guild already uses this hashtag. Choose a different display name.']);
}

if ($guild instanceof GuildSubmission) {
Expand Down
Loading