Skip to content

Commit 752f4f3

Browse files
committed
feat: completes api
1 parent 5be0cc2 commit 752f4f3

47 files changed

Lines changed: 1362 additions & 109 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎KNOWLEDGE_BASE.md‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ An app can use the same `/api/v1` for you with signed requests. It keeps an SSH
483483
A signed request sees what the web shows you, such as your own pending commits. It can also, with the web's validation, moderation, and rate limits:
484484

485485
- read your account, logs, replies, notifications (including grouped activity), and starred commits;
486-
- commit, reply, and quote, with images, and delete your commits;
486+
- commit, reply, and quote, with images, and delete your commits, with the same undo window as the web;
487487
- preview commit drafts without publishing them;
488488
- follow or unfollow, mute or unmute, and block or unblock, and list who you muted and blocked;
489489
- read who to follow, also as it is suggested beside a profile or a commit, and mark a suggestion not interested;
@@ -494,26 +494,36 @@ A signed request sees what the web shows you, such as your own pending commits.
494494
- stash or reopen conversations and orgs, pin and mute them, merge or drop message requests, and send typing indicators;
495495
- switch Pastéis mode and give pastéis;
496496
- report commits;
497-
- sync from GitHub and save your lane color;
497+
- search people by name or handle, and commits by meaning, with the web's limit of 15 commit searches a minute;
498+
- schedule commits, list your queue, cancel a scheduled commit, or post it early;
499+
- pin a commit to your profile, or unpin it;
500+
- translate commits;
501+
- suggest people to mention and /dev/null issues to reference while writing;
502+
- sync from GitHub, save your lane color, timezone, and translation language, and turn automatic translation on or off;
503+
- list your devices and revoke them;
498504
- delete your account.
499505

500-
Signed request bodies are JSON, or multipart when they carry images or a voice note, so app commits can have images with descriptions or a poll but no link-card choice. Before your first app submission, accept the [commit rules](#moderation) through the web composer. Scheduling, search, and translations remain web-only. Signed requests are limited to **120 requests per minute per user**. Settings → Devices lists your approved devices with when each was last used, and revokes them.
506+
Signed request bodies are JSON, or multipart when they carry images or a voice note, so app commits can have images with descriptions or a poll but no link-card choice. Before your first app submission, accept the [commit rules](#moderation) through the web composer. Signed requests are limited to **120 requests per minute per user**. Settings → Devices lists your approved devices with when each was last used, and revokes them.
501507

502508
Sources: [signed requests](app/Services/SignedRequests.php), [sign-in page](app/Http/Controllers/MobileAuthorizationController.php), [devices settings](resources/js/pages/device/index.tsx), [API routes](routes/api.php).
503509

504510
### Mac app
505511

506-
**/dev/null for Mac** is a native Mac app for Remotes: direct remotes and orgs with replies, reactions, images, link cards, voice notes, pull receipts, and notifications. It is free, universal (Apple silicon and Intel), and requires macOS 14 or later. Download it from **/apps**, the home for /dev/null's apps, which shows the version, size, release date, and SHA-256 checksum of the current download (`/mac` redirects there, and **Settings → Devices** links to it).
512+
**/dev/null for Mac** is a native Mac app for all of /dev/null: the Following, Latest, and Trending logs, writing and scheduling commits, replies, quotes, polls, stars, Starred, notifications, profiles, search, and Remotes. It is free, universal (Apple silicon and Intel), and requires macOS 14 or later. Download it from **/apps**, the home for /dev/null's apps, which shows the version, size, release date, and SHA-256 checksum of the current download (`/mac` redirects there, and **Settings → Devices** links to it).
507513

508514
To install it, open `DevNull.dmg`, drag /dev/null onto Applications, and open it. The file is named `DevNull.app`, because a slash can't go in a file name; everywhere else, the app is called /dev/null. The app is signed and notarized by Apple, so macOS opens it without a warning.
509515

510-
On first launch, choose **Sign in with GitHub**: the app opens `/mobile/authorize` in your browser, you approve its key, and the Mac shows up under **Settings → Devices** like any other device, where you can revoke it. It uses the same signed API as the phone app, with the same limits, and gets new messages by polling while it runs; there are no push notifications after you quit it.
516+
On first launch, choose **Sign in with GitHub**: the app opens `/mobile/authorize` in your browser, you approve its key, and the Mac shows up under **Settings → Devices** like any other device, where you can revoke it. It uses the same signed API as the phone app, with the same limits, moderation, and rules as the web.
511517

512-
Privacy on the Mac: the device key stays in the Keychain, notification banners never show what a message says, and messages and images are kept in memory only, so besides a few preferences nothing is saved on the Mac. **Sign Out** deletes the key.
518+
The window is a workspace. The sidebar lists everything you can read in three sections: **Logs** (Following, Latest, Trending), **Remotes** (your pinned and recent remotes and orgs, All Remotes, and Stashed), and **You** (Notifications, Starred, Scheduled, and your profile). The middle shows what you picked, and every log is drawn on the same `git log --graph` rail as the web. Replies open in a pane on the right, so the log never moves; profiles, commit pages, and search results open in the middle with Back and Forward. **⌘K** searches people, remotes, and commits by meaning. Every action is in the menu bar with a shortcut, the web's keyboard shortcuts work in any list, and **?** shows them. **⌘N** writes a new commit; **⇧⌘N** starts a new remote and **⌥⇧⌘N** a new org.
519+
520+
Logs and notifications are checked about every 30 seconds while the app is in front and every few minutes in the background, and new commits wait behind a button instead of moving what you are reading. A log's new-commit count is a quiet number, never a badge; the Dock badge counts unread remotes and notifications only. Activity never shows a banner, and remote banners never show what a message says. There are no push notifications after you quit the app.
521+
522+
Privacy on the Mac: the device key stays in the Keychain, and commits, messages, notifications, profiles, and images are kept in memory only, so besides a few preferences nothing is saved on the Mac. Drafts last until you quit /dev/null. Your profile is mirrored from GitHub and edited there, never in the app; data export and account settings that live on the web open in your browser. **Sign Out** deletes the key.
513523

514524
Updates: **Check for Updates…** in the app menu compares the installed build with the one /apps offers and opens /apps when there is a newer one; the app also checks quietly once a day while it runs. The check is an unsigned request that sends nothing about you or your account. To update, download the new DMG and replace the app in Applications; you stay signed in. The **About /dev/null** window shows the version and build, links to the site, /apps, the privacy policy and Manage Devices, and credits.
515525

516-
Sources: [apps page](resources/js/pages/app/index.tsx), [release endpoint](app/Http/Controllers/Api/MacAppController.php), [About window](https://github.com/dev-null-sh/mac-os-app/blob/main/Sources/DevNull/Views/AboutView.swift), [update check](https://github.com/dev-null-sh/mac-os-app/blob/main/Sources/DevNull/App/Updates.swift), [API routes](routes/api.php).
526+
Sources: [apps page](resources/js/pages/app/index.tsx), [release endpoint](app/Http/Controllers/Api/MacAppController.php), [design](https://github.com/dev-null-sh/mac-os-app/blob/main/DESIGN.md), [About window](https://github.com/dev-null-sh/mac-os-app/blob/main/Sources/DevNull/Views/AboutView.swift), [update check](https://github.com/dev-null-sh/mac-os-app/blob/main/Sources/DevNull/App/Updates.swift), [API routes](routes/api.php).
517527

518528
### Bug reports and feature requests
519529

‎PRODUCT.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Developers who left X or Bluesky, or are thinking about it, and want a feed with
2222

2323
## Operating Context
2424

25-
- Surfaces: the web app (also installable as a PWA), the mobile app and the Mac app (Remotes, downloadable from /apps) through a signed JSON API, the terminal script and GitHub Action, a public read-only API, Atom feeds, and an activity graph SVG for GitHub READMEs.
25+
- Surfaces: the web app (also installable as a PWA), the mobile app and the Mac app (the whole product as a native workspace, downloadable from /apps) through a signed JSON API, the terminal script and GitHub Action, a public read-only API, Atom feeds, and an activity graph SVG for GitHub READMEs.
2626
- Guests can read the Latest and Trending logs, profiles, approved commits and their threads, and search. Everything that writes or is personal (Following log, notifications, Saved, Remotes, Settings) needs sign-in.
2727
- Site admins (`ADMINS`) moderate (`/moderation`) and run the site (`/operations`).
2828
- Exact behavior, limits, and edge cases for every feature live in [KNOWLEDGE_BASE.md](KNOWLEDGE_BASE.md) and in the code; this file only records what must stay true.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Actions\DeleteCommitPin;
8+
use App\Actions\UpdateCommitPin;
9+
use App\Http\Requests\DeleteApiCommitPinRequest;
10+
use App\Http\Requests\UpdateApiCommitPinRequest;
11+
use App\Http\Resources\CommitResource;
12+
use App\Models\Commit;
13+
use App\Models\User;
14+
use App\Queries\CommitPageQuery;
15+
use Illuminate\Container\Attributes\CurrentUser;
16+
17+
final readonly class CommitPinController
18+
{
19+
/**
20+
* Pins the commit to the top of the user's profile, in place of the one pinned before, and answers with the commit
21+
* as its page shows it, so the app gets the new is_pinned.
22+
*/
23+
public function update(UpdateApiCommitPinRequest $request, #[CurrentUser] User $user, Commit $commit, UpdateCommitPin $action, CommitPageQuery $page): CommitResource
24+
{
25+
$action->handle($user, $commit);
26+
27+
return CommitResource::make($page->get($commit, $user));
28+
}
29+
30+
public function destroy(DeleteApiCommitPinRequest $request, #[CurrentUser] User $user, Commit $commit, DeleteCommitPin $action, CommitPageQuery $page): CommitResource
31+
{
32+
$action->handle($user, $commit);
33+
34+
return CommitResource::make($page->get($commit, $user));
35+
}
36+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Actions\CreateCommitRestoration;
8+
use App\Http\Requests\CreateApiCommitRestorationRequest;
9+
use App\Http\Resources\CommitResource;
10+
use App\Models\Commit;
11+
use App\Models\User;
12+
use App\Queries\CommitPageQuery;
13+
use Illuminate\Container\Attributes\CurrentUser;
14+
15+
final readonly class CommitRestorationController
16+
{
17+
/**
18+
* Undoes deleting the user's commit within the undo window, as Undo on the web does, and answers with the commit
19+
* as its page shows it.
20+
*/
21+
public function store(CreateApiCommitRestorationRequest $request, #[CurrentUser] User $user, Commit $commit, CreateCommitRestoration $action, CommitPageQuery $page): CommitResource
22+
{
23+
return CommitResource::make($page->get($action->handle($commit), $user));
24+
}
25+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Http\Requests\ListApiCommitSearchRequest;
8+
use App\Http\Resources\CommitResource;
9+
use App\Models\User;
10+
use App\Queries\CommitSearchQuery;
11+
use App\Queries\ReplyPreviewsQuery;
12+
use Illuminate\Container\Attributes\CurrentUser;
13+
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
14+
15+
final readonly class CommitSearchController
16+
{
17+
/**
18+
* The commits nearest in meaning to the term, closest first, as the web's search finds them, which may be fewer than
19+
* asked for once the irrelevant ones are left out.
20+
*/
21+
public function index(ListApiCommitSearchRequest $request, #[CurrentUser] User $user, CommitSearchQuery $search, ReplyPreviewsQuery $replyPreviews): AnonymousResourceCollection
22+
{
23+
$commits = $search->get($request->string('q')->value(), $user, $request->limit());
24+
25+
$replyPreviews->load($commits->all(), $user);
26+
27+
return CommitResource::collection($commits);
28+
}
29+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Actions\CreateCommitTranslation;
8+
use App\Exceptions\CommitProcessingFailed;
9+
use App\Http\Requests\CreateApiCommitTranslationRequest;
10+
use App\Models\Commit;
11+
use App\Services\CommitTranslations;
12+
use Illuminate\Http\JsonResponse;
13+
use Throwable;
14+
15+
final readonly class CommitTranslationController
16+
{
17+
/**
18+
* The commit in the language asked for, as Translate on the web shows it. A failed translation is a 503 the app
19+
* can retry, with the same message the web shows.
20+
*/
21+
public function store(CreateApiCommitTranslationRequest $request, Commit $commit, CreateCommitTranslation $action, CommitTranslations $translations): JsonResponse
22+
{
23+
try {
24+
$action->handle($commit, $request->string('language')->value());
25+
} catch (Throwable $throwable) {
26+
report($throwable instanceof CommitProcessingFailed ? $throwable : new CommitProcessingFailed('Translation', $commit->id, $throwable));
27+
28+
$message = $throwable instanceof CommitProcessingFailed && $throwable->reason === 'unsupported_source_language'
29+
? 'The translation service returned an unsupported source language. Try again.'
30+
: 'Could not translate this commit. Try again.';
31+
32+
return response()->json(['message' => $message], 503)
33+
->header('Cache-Control', 'no-store, private');
34+
}
35+
36+
return response()->json(['translation' => $translations->display($commit, $request->string('language')->value(), includePending: true)])
37+
->header('Cache-Control', 'no-store, private');
38+
}
39+
}

‎app/Http/Controllers/Api/DeviceController.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@
55
namespace App\Http\Controllers\Api;
66

77
use App\Actions\CreateDevice;
8+
use App\Actions\DeleteDevice;
89
use App\Actions\UpdateUserTermsAcceptance;
910
use App\Exceptions\ApiException;
1011
use App\Http\Requests\CreateApiDeviceRequest;
12+
use App\Http\Requests\DeleteApiDeviceRequest;
1113
use App\Http\Resources\CurrentUserResource;
14+
use App\Http\Resources\DeviceResource;
1215
use App\Models\Device;
16+
use App\Models\User;
1317
use App\Queries\NotificationGroupsQuery;
18+
use Illuminate\Container\Attributes\CurrentUser;
1419
use Illuminate\Http\JsonResponse;
20+
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
21+
use Illuminate\Http\Response;
1522
use Illuminate\Support\Facades\Auth;
1623

1724
final readonly class DeviceController
1825
{
26+
/**
27+
* The devices that may sign requests as the user, newest approval first, as the web's Devices page lists them.
28+
*/
29+
public function index(#[CurrentUser] User $user): AnonymousResourceCollection
30+
{
31+
return DeviceResource::collection($user->devices()->latest('approved_at')->get());
32+
}
33+
1934
/**
2035
* Approves the key that signed the request as a device, for the user who approved the app on the web, and answers
2136
* as GET /api/v1/me does. A code redeemed by another request in the meantime gets the same answer as a wrong one.
@@ -38,4 +53,14 @@ public function store(CreateApiDeviceRequest $request, CreateDevice $action, Upd
3853
'unread_notifications_count' => $notifications->unreadCount($device->user),
3954
]);
4055
}
56+
57+
/**
58+
* Revokes the device. Revoking the one that signed the request signs the app out on it.
59+
*/
60+
public function destroy(DeleteApiDeviceRequest $request, Device $device, DeleteDevice $action): Response
61+
{
62+
$action->handle($device);
63+
64+
return response()->noContent();
65+
}
4166
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Http\Requests\ListApiIssueSuggestionsRequest;
8+
use App\Queries\IssueSuggestionsQuery;
9+
use Illuminate\Http\JsonResponse;
10+
11+
final readonly class IssueSuggestionController
12+
{
13+
/**
14+
* The /dev/null issue with that number, as the web's composer suggests it, or null.
15+
*/
16+
public function index(ListApiIssueSuggestionsRequest $request, IssueSuggestionsQuery $suggestions): JsonResponse
17+
{
18+
return response()->json(['issue' => $suggestions->get($request->integer('q'))]);
19+
}
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Http\Requests\ListApiMentionSuggestionsRequest;
8+
use App\Http\Resources\UserResource;
9+
use App\Models\User;
10+
use App\Queries\MentionSuggestionsQuery;
11+
use Illuminate\Container\Attributes\CurrentUser;
12+
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
13+
14+
final readonly class MentionSuggestionController
15+
{
16+
/**
17+
* The people the composer suggests for an @mention, as the web's composer suggests them.
18+
*/
19+
public function index(ListApiMentionSuggestionsRequest $request, #[CurrentUser] User $user, MentionSuggestionsQuery $suggestions): AnonymousResourceCollection
20+
{
21+
return UserResource::collection($suggestions->get($user, $request->string('q')->value(), $request->org(), reply: $request->reply(), quote: $request->quote()));
22+
}
23+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Http\Controllers\Api;
6+
7+
use App\Actions\CreateScheduledCommit;
8+
use App\Actions\DeleteScheduledCommit;
9+
use App\Http\Requests\CreateApiScheduledCommitRequest;
10+
use App\Http\Requests\DeleteApiScheduledCommitRequest;
11+
use App\Http\Resources\ScheduledCommitResource;
12+
use App\Models\ScheduledCommit;
13+
use App\Models\User;
14+
use App\Queries\ScheduledCommitsQuery;
15+
use Carbon\CarbonImmutable;
16+
use Illuminate\Container\Attributes\CurrentUser;
17+
use Illuminate\Http\JsonResponse;
18+
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
19+
use Illuminate\Http\Response;
20+
21+
final readonly class ScheduledCommitController
22+
{
23+
/**
24+
* The user's queue, as the web's Scheduled page lists it, 20 a page.
25+
*/
26+
public function index(#[CurrentUser] User $user, ScheduledCommitsQuery $scheduled): AnonymousResourceCollection
27+
{
28+
return ScheduledCommitResource::collection($scheduled->builder($user)->paginate(20));
29+
}
30+
31+
/**
32+
* Only the user sees a scheduled commit until it is submitted.
33+
*/
34+
public function store(CreateApiScheduledCommitRequest $request, #[CurrentUser] User $user, CreateScheduledCommit $action): JsonResponse
35+
{
36+
$scheduled = $action->handle($user, $request->string('body')->value(), CarbonImmutable::parse($request->string('scheduled_at')->value())->utc(), $request->images(), $request->imageDescriptions(), $request->poll(), $request->linkPreview());
37+
38+
return ScheduledCommitResource::make($scheduled)
39+
->response()
40+
->setStatusCode(201);
41+
}
42+
43+
/**
44+
* One that was already submitted or canceled can't be canceled, so the app is told to refresh, as the web says.
45+
*/
46+
public function destroy(DeleteApiScheduledCommitRequest $request, #[CurrentUser] User $user, ScheduledCommit $scheduledCommit, DeleteScheduledCommit $action): Response|JsonResponse
47+
{
48+
return $action->handle($user, $scheduledCommit)
49+
? response()->noContent()
50+
: response()->json(['message' => 'This commit was already submitted or canceled. Refresh to see its status.'], 409);
51+
}
52+
}

0 commit comments

Comments
 (0)