Skip to content
Draft
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
1 change: 1 addition & 0 deletions KNOWLEDGE_BASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ An app can use the same `/api/v1` for you with signed requests. It keeps an SSH
A signed request sees what the web shows you, such as your own pending commits and your organizations'. It can also, with the web's validation, moderation, and rate limits:

- read your account, logs, replies, notifications (including grouped activity), and starred commits;
- read a profile's activity graph over the same range as the web: the last 24 hours, 7 days, 30 days, 6 months, or a year;
- read the organizations you are a member of, your role in each, and whether posting as an organization is switched on;
- open the person or organization a mention in a commit or message captured, by the id each mention carries, as the web's mention links do, so it still leads to them after they rename and someone else takes the handle;
- commit, reply, and quote, with images, and delete your commits, with the same undo window as the web;
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Http\Controllers\Api;

use App\Enums\ActivityScale;
use App\Http\Requests\ShowApiUserRequest;
use App\Http\Resources\CommitResource;
use App\Http\Resources\UserResource;
Expand Down Expand Up @@ -40,8 +39,7 @@ public function show(ShowApiUserRequest $request, #[CurrentUser] ?User $currentU
'follows_you' => $user->isFollowing($currentUser),
'is_muting' => $currentUser->isMuting($user),
'pasteis_received' => $user->pasteis_received,
// API clients don't know the half-year scale yet, so they keep getting the year for anyone past a month.
'activity' => $activity->get($user, $currentUser, scales: [ActivityScale::Day, ActivityScale::Week, ActivityScale::Month]),
'activity' => $activity->get($user, $currentUser),
'streaks' => $userStreaks,
'achievements' => $achievements->get($user, $currentUser, $userStreaks),
'pinned_commit' => $pinnedCommit instanceof Commit ? CommitResource::make($pinnedCommit) : null,
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/Controllers/Api/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
expect(json_decode($response->getContent(), flags: JSON_THROW_ON_ERROR)->bio_profiles)->toBeInstanceOf(stdClass::class);
});

it('keeps API clients on the year for a profile whose first visible commit is two months old', function (): void {
it('returns the half scale for a profile whose first visible commit is two months old', function (): void {
$this->travelTo(now()->setDate(2026, 10, 15)->setTime(12, 0));

$keyPair = apiKeyPairFor(User::factory()->create());
Expand All @@ -190,9 +190,9 @@

signedApiRequest($keyPair, 'GET', route('api-user.show', $user))
->assertOk()
->assertJsonPath('activity.scale', 'year')
->assertJsonCount(369, 'activity.buckets')
->assertJsonPath('activity.buckets.0.date', '2025-10-12');
->assertJsonPath('activity.scale', 'half')
->assertJsonCount(180, 'activity.buckets')
->assertJsonPath('activity.buckets.0.date', '2026-04-19');
});

it('counts the pending commits of a signed-in user on their own profile', function (): void {
Expand Down