Repository navigation
feat: let a guild's moderator hand moderation to another member #1602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kachelle
wants to merge
6
commits into
dev-null-sh:production
Choose a base branch
from
kachelle:feat/edit-guild-moderator
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+695
−24
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9c52759
feat: let a guild's moderator hand moderation to another member
kachelle 0999db0
fix: only hand guilds to members who can open them, and recheck the g…
kachelle 99747d5
fix: recount guilds under the lock when creating one, and drop the pr…
kachelle 79e1890
Merge branch 'production' into feat/edit-guild-moderator
kachelle de09b6d
fix: recheck a handover's moderator removal under the guild lock
kachelle 8d4c627
fix: refuse a handover saved with changes that wait for review
kachelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 GuildModeratorLimitReached extends RuntimeException {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 GuildModeratorNotMember extends RuntimeException {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 GuildModeratorPreviouslyRemoved extends RuntimeException {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Http\Requests\ListGuildMemberSuggestionsRequest; | ||
| use App\Models\Guild; | ||
| use App\Queries\GuildMemberSuggestionsQuery; | ||
| use Illuminate\Http\JsonResponse; | ||
|
|
||
| final readonly class GuildMemberSuggestionController | ||
| { | ||
| public function index(ListGuildMemberSuggestionsRequest $request, Guild $guild, GuildMemberSuggestionsQuery $suggestions): JsonResponse | ||
| { | ||
| return response()->json(['members' => $suggestions->get($guild, $request->string('q')->value())]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Http\Requests; | ||
|
|
||
| use App\Enums\Feature; | ||
| use App\Models\Guild; | ||
| use App\Services\Features; | ||
| use Illuminate\Auth\Access\Response; | ||
| use Illuminate\Foundation\Http\FormRequest; | ||
|
|
||
| final class ListGuildMemberSuggestionsRequest extends FormRequest | ||
| { | ||
| /** | ||
| * Only the moderator picks who takes over, so only they search the members. | ||
| */ | ||
| public function authorize(Features $features): Response | ||
| { | ||
| $guild = $this->route('guild'); | ||
| assert($guild instanceof Guild); | ||
|
|
||
| return $features->available(Feature::Guilds, $this->user()) && $guild->user_id === $this->user()?->id | ||
| ? Response::allow() : Response::denyAsNotFound(); | ||
| } | ||
|
|
||
| /** @return array<string, list<string>> */ | ||
| public function rules(): array | ||
| { | ||
| return ['q' => ['nullable', 'string', 'max:60']]; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not silently discard the edit submitted with a handover.
If a save includes a flagged description and a handover, this assignment makes the queued edit ineligible for approval. Approval selects
CreateGuildbecause the submission author no longer owns the guild. That action leaves the new moderator's guild unchanged and deletes the submission. The controller nevertheless promises that approval will publish the changes. The new test at Lines 1372-1391 accepts this loss. (raw.githubusercontent.com)Keep the edit reviewable after handover, or reject the combined save before changing ownership. Preserve immediate handover for saves without flagged changes.