Repository navigation
Expand file tree
/
Copy pathapi.php
More file actions
596 lines (534 loc) · 34.9 KB
/
Copy pathapi.php
File metadata and controls
596 lines (534 loc) · 34.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<?php
declare(strict_types=1);
use App\Exceptions\ApiException;
use App\Http\Controllers\Api\BroadcastAuthorizationController;
use App\Http\Controllers\Api\CallController;
use App\Http\Controllers\Api\CommitController as ApiCommitController;
use App\Http\Controllers\Api\CommitPastelController;
use App\Http\Controllers\Api\CommitPinController;
use App\Http\Controllers\Api\CommitPollVoteController;
use App\Http\Controllers\Api\CommitPreviewController;
use App\Http\Controllers\Api\CommitReplyController;
use App\Http\Controllers\Api\CommitReportController;
use App\Http\Controllers\Api\CommitRestorationController;
use App\Http\Controllers\Api\CommitSearchController;
use App\Http\Controllers\Api\CommitStarController;
use App\Http\Controllers\Api\CommitTranslationController;
use App\Http\Controllers\Api\ConversationArchiveController;
use App\Http\Controllers\Api\ConversationCallController;
use App\Http\Controllers\Api\ConversationCallIceServerController;
use App\Http\Controllers\Api\ConversationController;
use App\Http\Controllers\Api\ConversationDropController;
use App\Http\Controllers\Api\ConversationMergeController;
use App\Http\Controllers\Api\ConversationMessageController;
use App\Http\Controllers\Api\ConversationMuteController;
use App\Http\Controllers\Api\ConversationPinController;
use App\Http\Controllers\Api\ConversationPingController;
use App\Http\Controllers\Api\ConversationReadController;
use App\Http\Controllers\Api\ConversationTypingController;
use App\Http\Controllers\Api\CurrentUserController;
use App\Http\Controllers\Api\DeviceController;
use App\Http\Controllers\Api\DevicePushTokenController;
use App\Http\Controllers\Api\GuildCommitPinController;
use App\Http\Controllers\Api\GuildController;
use App\Http\Controllers\Api\GuildIconController;
use App\Http\Controllers\Api\GuildMembershipController;
use App\Http\Controllers\Api\GuildMuteController;
use App\Http\Controllers\Api\GuildReadController;
use App\Http\Controllers\Api\GuildReportController;
use App\Http\Controllers\Api\HeadlineController;
use App\Http\Controllers\Api\IssueController;
use App\Http\Controllers\Api\IssueSuggestionController;
use App\Http\Controllers\Api\JoinedGuildController;
use App\Http\Controllers\Api\LiveFollowingController;
use App\Http\Controllers\Api\LogController;
use App\Http\Controllers\Api\MentionSuggestionController;
use App\Http\Controllers\Api\MessageImageController;
use App\Http\Controllers\Api\MessageLinkPreviewController;
use App\Http\Controllers\Api\MessagePinController;
use App\Http\Controllers\Api\MessageReactionController;
use App\Http\Controllers\Api\MessageVoiceController;
use App\Http\Controllers\Api\NotificationController;
use App\Http\Controllers\Api\NotificationGroupController;
use App\Http\Controllers\Api\OrganizationAdminController;
use App\Http\Controllers\Api\OrganizationCommitController;
use App\Http\Controllers\Api\OrganizationController;
use App\Http\Controllers\Api\OrganizationFollowController;
use App\Http\Controllers\Api\OrganizationMentionController;
use App\Http\Controllers\Api\OrgArchiveController;
use App\Http\Controllers\Api\OrgCallController;
use App\Http\Controllers\Api\OrgCallIceServerController;
use App\Http\Controllers\Api\OrgController;
use App\Http\Controllers\Api\OrgMemberController;
use App\Http\Controllers\Api\OrgMessageController;
use App\Http\Controllers\Api\OrgMuteController;
use App\Http\Controllers\Api\OrgPinController;
use App\Http\Controllers\Api\OrgPingController;
use App\Http\Controllers\Api\OrgReadController;
use App\Http\Controllers\Api\OrgTypingController;
use App\Http\Controllers\Api\ProfileSearchController;
use App\Http\Controllers\Api\RelatedCommitController;
use App\Http\Controllers\Api\RemoteCandidateController;
use App\Http\Controllers\Api\ScheduledCommitController;
use App\Http\Controllers\Api\ScheduledCommitSubmissionController;
use App\Http\Controllers\Api\StarredCommitController;
use App\Http\Controllers\Api\SuggestedUserController;
use App\Http\Controllers\Api\SuggestionDismissalController;
use App\Http\Controllers\Api\UserAutomaticTranslationController;
use App\Http\Controllers\Api\UserBlockController;
use App\Http\Controllers\Api\UserCommitController;
use App\Http\Controllers\Api\UserController;
use App\Http\Controllers\Api\UserFollowController;
use App\Http\Controllers\Api\UserFollowedOrganizationController;
use App\Http\Controllers\Api\UserFollowersController;
use App\Http\Controllers\Api\UserFollowingController;
use App\Http\Controllers\Api\UserLaneController;
use App\Http\Controllers\Api\UserLiveController;
use App\Http\Controllers\Api\UserModerationHistoryController;
use App\Http\Controllers\Api\UserMuteController;
use App\Http\Controllers\Api\UserPasteisModeController;
use App\Http\Controllers\Api\UserProfileController;
use App\Http\Controllers\Api\UserPushPreferencesController;
use App\Http\Controllers\Api\UserRemotePreferencesController;
use App\Http\Controllers\Api\UserRemotesController;
use App\Http\Controllers\Api\UserSearchController;
use App\Http\Controllers\Api\UserSettingsController;
use App\Http\Controllers\Api\UserTermsController;
use App\Http\Controllers\Api\UserTimezoneController;
use App\Http\Controllers\Api\UserTranslationLanguageController;
use App\Http\Controllers\Api\WebSessionController;
use App\Http\Controllers\Cli\CommitController;
use App\Http\Controllers\Cli\KeyLookupController;
use App\Http\Middleware\AuthenticateSignedRequest;
use App\Http\Middleware\AuthenticateSshSignature;
use App\Http\Middleware\PreventPostingInTimeout;
use App\Http\Middleware\RequireCommitRules;
use App\Http\Middleware\ThrottleCommits;
use App\Http\Middleware\ThrottleIssues;
use App\Http\Middleware\UpdateLastSeenAt;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Http\JsonResponse;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Route;
Route::prefix('cli')->group(function (): void {
Route::post('commits', [CommitController::class, 'store'])
->middleware([AuthenticateSshSignature::class, PreventPostingInTimeout::class, RequireCommitRules::class, ThrottleCommits::class])
->name('cli-commit.store');
Route::post('key-lookups', [KeyLookupController::class, 'store'])
->middleware('throttle:60,1,key-lookups:')
->name('cli-key-lookup.store');
});
Route::prefix('v1')->middleware('throttle:api')->group(function (): void {
// Public, or as the web shows them to the user when signed by the mobile app...
Route::middleware(AuthenticateSignedRequest::optional())->group(function (): void {
Route::get('users/{user:handle}', [UserController::class, 'show'])
->name('api-user.show');
Route::get('users/{user:handle}/commits', [UserCommitController::class, 'index'])
->name('api-user-commit.index');
Route::get('commits/{commit}', [ApiCommitController::class, 'show'])
->name('api-commit.show');
Route::get('commits/{commit}/related', [RelatedCommitController::class, 'index'])
->name('api-related-commit.index');
Route::get('organizations/{handle}', [OrganizationController::class, 'show'])
->name('api-organization.show');
Route::get('organizations/{handle}/commits', [OrganizationCommitController::class, 'index'])
->name('api-organization-commit.index');
Route::get('organizations/{handle}/mentions', [OrganizationMentionController::class, 'index'])
->name('api-organization-mention.index');
// Mentioned profiles: the user or organization a commit's or message's mention captured, by the id it carries,
// as the web's mention links open them, so they still lead there once they rename...
Route::get('mentions/{user}', [UserController::class, 'show'])
->whereUuid('user')
->name('api-mentioned-user.show');
Route::get('mentions/organizations/{organization}', [OrganizationController::class, 'show'])
->whereUuid('organization')
->name('api-mentioned-organization.show');
});
// Signing in: the app redeems the code it got on the web, signed with a key that isn't approved yet...
Route::post('devices', [DeviceController::class, 'store'])
->withoutMiddleware('throttle:api')
->middleware('throttle:devices')
->name('api-device.store');
// Remote images, voice notes and guild icons: the app's image views and audio players can't sign requests, so the API hands out URLs signed for the user...
Route::get('remotes/images/{messageImage}', [MessageImageController::class, 'show'])
->whereUuid('messageImage')
->withoutMiddleware('throttle:api')
->middleware('signed:relative')
->name('api-message-image.show');
Route::get('remotes/voices/{messageVoice}', [MessageVoiceController::class, 'show'])
->whereUuid('messageVoice')
->withoutMiddleware('throttle:api')
->middleware('signed:relative')
->name('api-message-voice.show');
Route::get('guilds/{guild:handle}/icon', [GuildIconController::class, 'show'])
->withoutMiddleware('throttle:api')
->middleware('signed:relative')
->name('api-guild-icon.show');
// Signed by the mobile app with an SSH key that the user approved as a device...
Route::middleware(AuthenticateSignedRequest::class)->group(function (): void {
Route::get('me', [CurrentUserController::class, 'show'])->name('api-current-user.show');
// Live updates, on the user's own private channel...
Route::post('broadcasting/auth', [BroadcastAuthorizationController::class, 'store'])
->middleware('throttle:broadcast-authorizations')
->name('api-broadcast-authorization.store');
Route::delete('me', [CurrentUserController::class, 'destroy'])->name('api-current-user.destroy');
// Pastéis...
Route::put('me/pasteis-mode', [UserPasteisModeController::class, 'update'])->name('api-user-pasteis-mode.update');
Route::put('me/terms', [UserTermsController::class, 'update'])->name('api-user-terms.update');
// User Profile: mirrored from GitHub again, as Sync from GitHub does on the web...
Route::put('me/github', [UserProfileController::class, 'update'])
->middleware('throttle:profile-syncs')
->name('api-user-profile.update');
// User Lane...
Route::put('me/lane', [UserLaneController::class, 'update'])->name('api-user-lane.update');
// User Live: the stream the user is on, as Go live and End stream do on the web...
Route::put('me/live', [UserLiveController::class, 'update'])
->middleware(PreventPostingInTimeout::class)
->name('api-user-live.update');
Route::delete('me/live', [UserLiveController::class, 'destroy'])->name('api-user-live.destroy');
Route::get('me/live-following', [LiveFollowingController::class, 'index'])->name('api-live-following.index');
// User Settings: what the web's settings show only the user...
Route::get('me/settings', [UserSettingsController::class, 'show'])->name('api-user-settings.show');
// User Moderation History: the timeouts and bans the web shows on the user's own profile...
Route::get('me/moderation-history', [UserModerationHistoryController::class, 'show'])->name('api-user-moderation-history.show');
// User Timezone and Translation, as the web's settings save them...
Route::put('me/timezone', [UserTimezoneController::class, 'update'])->name('api-user-timezone.update');
Route::put('me/automatic-translation', [UserAutomaticTranslationController::class, 'update'])->name('api-user-automatic-translation.update');
Route::put('me/translation-language', [UserTranslationLanguageController::class, 'update'])->name('api-user-translation-language.update');
// Devices: the keys approved to sign as the user, as the web's Devices page lists and revokes them...
Route::get('me/devices', [DeviceController::class, 'index'])->name('api-device.index');
Route::delete('me/devices/{device}', [DeviceController::class, 'destroy'])
->whereUuid('device')
->name('api-device.destroy');
// Web session: the lite mobile app's web view signs in with cookies made for the device. It isn't a visit: the page it loads next is...
Route::post('me/web-session', [WebSessionController::class, 'store'])
->withoutMiddleware(UpdateLastSeenAt::class)
->middleware([EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class])
->name('api-web-session.store');
// Push notifications: the token pushes reach the phone that signs the request with, and what the user wants pushed...
Route::put('me/push-token', [DevicePushTokenController::class, 'update'])->name('api-device-push-token.update');
Route::delete('me/push-token', [DevicePushTokenController::class, 'destroy'])->name('api-device-push-token.destroy');
Route::put('me/push-preferences', [UserPushPreferencesController::class, 'update'])->name('api-user-push-preferences.update');
// Who follows whom, for members like on the web, so scrapers can't walk the graph...
Route::get('users/{user:handle}/followers', [UserFollowersController::class, 'index'])
->name('api-user-followers.index');
Route::get('users/{user:handle}/following', [UserFollowingController::class, 'index'])
->name('api-user-following.index');
Route::get('users/{user:handle}/following/organizations', [UserFollowedOrganizationController::class, 'index'])
->name('api-user-followed-organization.index');
// Search: people and organizations by name or handle, and commits by meaning, as the web's search finds them...
Route::get('search/profiles', [ProfileSearchController::class, 'index'])
->middleware('throttle:people')
->name('api-profile-search.index');
// Deprecated for search/profiles, kept for the apps that still call it...
Route::get('search/users', [UserSearchController::class, 'index'])
->middleware('throttle:people')
->name('api-user-search.index');
Route::get('search/commits', [CommitSearchController::class, 'index'])
->middleware('throttle:search')
->name('api-commit-search.index');
// Hot topics: the headlines the web's aside shows, and each one's page with its recap...
Route::get('headlines', [HeadlineController::class, 'index'])->name('api-headline.index');
Route::get('headlines/{headline}', [HeadlineController::class, 'show'])
->whereUuid('headline')
->name('api-headline.show');
// Guilds: the directory the web's Guilds page lists, a guild's board and its members...
Route::get('guilds', [GuildController::class, 'index'])->name('api-guild.index');
Route::post('guilds', [GuildController::class, 'store'])
->middleware([PreventPostingInTimeout::class, 'throttle:10,1,guilds:'])
->name('api-guild.store');
Route::get('guilds/{guild:handle}', [GuildController::class, 'show'])->name('api-guild.show');
Route::put('guilds/{guild:handle}', [GuildController::class, 'update'])
->middleware([PreventPostingInTimeout::class, 'throttle:10,1,guilds:'])
->name('api-guild.update');
Route::get('guilds/{guild:handle}/members', [GuildMembershipController::class, 'index'])->name('api-guild-membership.index');
// Joined guilds: the ones the web's left navigation lists, with the number of commits missed since the last visit...
Route::get('me/guilds', [JoinedGuildController::class, 'index'])->name('api-joined-guild.index');
Route::put('guilds/{guild:handle}/read', [GuildReadController::class, 'update'])
->middleware('throttle:120,1,guild-reads:')
->name('api-guild-read.update');
// Composer suggestions: people to mention and /dev/null issues to reference, as the web's composer suggests them...
Route::get('search/mentions', [MentionSuggestionController::class, 'index'])
->middleware('throttle:people')
->name('api-mention-suggestion.index');
Route::get('search/issues', [IssueSuggestionController::class, 'index'])
->middleware('throttle:issue-suggestions')
->name('api-issue-suggestion.index');
// Feature requests and bug reports, opened on GitHub as the web's /feature and /bug commands open them...
Route::post('issues', [IssueController::class, 'store'])
->middleware([PreventPostingInTimeout::class, 'throttle:10,1,issues:', ThrottleIssues::class])
->name('api-issue.store');
// User Remotes: the switch from the web's settings, and the settings menu on its Remotes page...
Route::put('me/remotes', [UserRemotesController::class, 'update'])->name('api-user-remotes.update');
Route::put('me/remote-preferences', [UserRemotePreferencesController::class, 'update'])
->middleware('throttle:conversations')
->name('api-user-remote-preferences.update');
// Log...
Route::get('log/{log}', [LogController::class, 'show'])->name('api-log.show');
// Commit...
Route::post('commits', [ApiCommitController::class, 'store'])
->middleware([PreventPostingInTimeout::class, RequireCommitRules::class, ThrottleCommits::class])
->name('api-commit.store');
Route::delete('commits/{commit}', [ApiCommitController::class, 'destroy'])->name('api-commit.destroy');
// Commit Restoration: undoing a deletion within its undo window...
Route::post('commits/{commit}/restoration', [CommitRestorationController::class, 'store'])
->withTrashed()
->name('api-commit-restoration.store');
// Scheduled Commits: the queue only the user sees until each one is submitted...
Route::get('scheduled-commits', [ScheduledCommitController::class, 'index'])->name('api-scheduled-commit.index');
Route::post('scheduled-commits', [ScheduledCommitController::class, 'store'])
->middleware([PreventPostingInTimeout::class, RequireCommitRules::class, ThrottleCommits::class])
->name('api-scheduled-commit.store');
Route::delete('scheduled-commits/{scheduledCommit}', [ScheduledCommitController::class, 'destroy'])
->whereUuid('scheduledCommit')
->name('api-scheduled-commit.destroy');
Route::post('scheduled-commits/{scheduledCommit}/submission', [ScheduledCommitSubmissionController::class, 'store'])
->whereUuid('scheduledCommit')
->middleware([PreventPostingInTimeout::class, ThrottleCommits::class])
->name('api-scheduled-commit-submission.store');
// Commit Pin: the author's commit at the top of their profile...
Route::put('commits/{commit}/pin', [CommitPinController::class, 'update'])
->middleware('throttle:pins')
->name('api-commit-pin.update');
Route::delete('commits/{commit}/pin', [CommitPinController::class, 'destroy'])
->middleware('throttle:pins')
->name('api-commit-pin.destroy');
// Commit Translation...
Route::post('commits/{commit}/translation', [CommitTranslationController::class, 'store'])
->middleware('throttle:10,1,translations:')
->name('api-commit-translation.store');
// Commit Preview: a draft as the commit it would become, which keeps nothing...
Route::post('commits/preview', [CommitPreviewController::class, 'store'])->name('api-commit-preview.store');
// Commit Reply...
Route::get('commits/{commit}/replies', [CommitReplyController::class, 'index'])
->withTrashed()
->name('api-commit-reply.index');
// Commit Report: a commit that doesn't exist or was deleted gets the same answer as one the user may not see...
Route::post('commits/{commit}/reports', [CommitReportController::class, 'store'])
->middleware('throttle:commit-reports')
->missing(fn (): JsonResponse => ApiException::commitUnavailable()->render())
->name('api-commit-report.store');
// Commit Pastel...
Route::post('commits/{commit}/pasteis', [CommitPastelController::class, 'store'])
->middleware('throttle:60,1,pasteis:')
->name('api-commit-pastel.store');
// Commit Poll Vote...
Route::post('commits/{commit}/poll/votes', [CommitPollVoteController::class, 'store'])->name('api-commit-poll-vote.store');
// Private starred commits...
Route::get('starred', [StarredCommitController::class, 'index'])->name('api-starred.index');
// Commit Star...
Route::get('commits/{commit}/stars', [CommitStarController::class, 'index'])
->name('api-commit-star.index');
Route::post('commits/{commit}/star', [CommitStarController::class, 'store'])
->middleware('throttle:stars')
->name('api-commit-star.store');
Route::delete('commits/{commit}/star', [CommitStarController::class, 'destroy'])
->middleware('throttle:stars')
->name('api-commit-star.destroy');
// User Follow...
Route::post('users/{user:handle}/follow', [UserFollowController::class, 'store'])
->middleware('throttle:follows')
->name('api-user-follow.store');
Route::delete('users/{user:handle}/follow', [UserFollowController::class, 'destroy'])
->middleware('throttle:follows')
->name('api-user-follow.destroy');
// Organization Follow...
Route::post('organizations/{handle}/follow', [OrganizationFollowController::class, 'store'])
->middleware('throttle:follows')
->name('api-organization-follow.store');
Route::delete('organizations/{handle}/follow', [OrganizationFollowController::class, 'destroy'])
->middleware('throttle:follows')
->name('api-organization-follow.destroy');
// Organization Admin: claiming an organization's page, which GitHub confirms the user belongs to...
Route::post('organizations/{handle}/claim', [OrganizationAdminController::class, 'store'])
->middleware('throttle:10,1,organization-claims:')
->name('api-organization-admin.store');
// Guild Membership: joining or leaving a guild, as the web's Join button does...
Route::post('guilds/{guild:handle}/membership', [GuildMembershipController::class, 'store'])
->middleware('throttle:follows')
->name('api-guild-membership.store');
Route::delete('guilds/{guild:handle}/membership', [GuildMembershipController::class, 'destroy'])
->middleware('throttle:follows')
->name('api-guild-membership.destroy');
// Guild Report: a private report to the admins, as the web's Report button sends...
Route::post('guilds/{guild:handle}/reports', [GuildReportController::class, 'store'])
->middleware('throttle:10,1,guild-reports:')
->name('api-guild-report.store');
// Guild Mute: hiding a guild's commits from logs and search, as the web's Mute button does...
Route::post('guilds/{guild:handle}/mute', [GuildMuteController::class, 'store'])
->middleware('throttle:follows')
->name('api-guild-mute.store');
Route::delete('guilds/{guild:handle}/mute', [GuildMuteController::class, 'destroy'])
->middleware('throttle:follows')
->name('api-guild-mute.destroy');
// Guild Pin: the moderator featuring one commit on the guild's board, as the web's Pin to board does...
Route::put('guilds/{guild:handle}/commits/{commit}/pin', [GuildCommitPinController::class, 'update'])
->whereUuid('commit')
->withTrashed()
->middleware('throttle:pins')
->name('api-guild-commit-pin.update');
Route::delete('guilds/{guild:handle}/commits/{commit}/pin', [GuildCommitPinController::class, 'destroy'])
->whereUuid('commit')
->withTrashed()
->middleware('throttle:pins')
->name('api-guild-commit-pin.destroy');
// Who to Follow...
Route::get('me/suggested-users', [SuggestedUserController::class, 'index'])->name('api-suggested-user.index');
Route::post('users/{user:handle}/dismiss', [SuggestionDismissalController::class, 'store'])->name('api-suggestion-dismissal.store');
// User Mute...
Route::get('me/muted', [UserMuteController::class, 'index'])->name('api-user-mute.index');
Route::post('users/{user:handle}/mute', [UserMuteController::class, 'store'])->name('api-user-mute.store');
Route::delete('users/{user:handle}/mute', [UserMuteController::class, 'destroy'])->name('api-user-mute.destroy');
// User Block...
Route::get('me/blocked', [UserBlockController::class, 'index'])->name('api-user-block.index');
Route::post('users/{user:handle}/block', [UserBlockController::class, 'store'])->name('api-user-block.store');
Route::delete('users/{user:handle}/block', [UserBlockController::class, 'destroy'])->name('api-user-block.destroy');
// Remotes: stashing or muting a conversation or an org, and merging or dropping a fetched request...
Route::middleware('throttle:conversations')->group(function (): void {
Route::post('remotes/@{partner:handle}/archive', [ConversationArchiveController::class, 'store'])
->name('api-conversation-archive.store');
Route::delete('remotes/@{partner:handle}/archive', [ConversationArchiveController::class, 'destroy'])
->name('api-conversation-archive.destroy');
Route::post('remotes/orgs/{org}/archive', [OrgArchiveController::class, 'store'])
->whereUuid('org')
->name('api-org-archive.store');
Route::delete('remotes/orgs/{org}/archive', [OrgArchiveController::class, 'destroy'])
->whereUuid('org')
->name('api-org-archive.destroy');
Route::put('remotes/@{partner:handle}/mute', [ConversationMuteController::class, 'update'])
->name('api-conversation-mute.update');
Route::put('remotes/@{partner:handle}/pin', [ConversationPinController::class, 'update'])
->name('api-conversation-pin.update');
Route::put('remotes/orgs/{org}/mute', [OrgMuteController::class, 'update'])
->whereUuid('org')
->name('api-org-mute.update');
Route::put('remotes/orgs/{org}/pin', [OrgPinController::class, 'update'])
->whereUuid('org')
->name('api-org-pin.update');
Route::post('remotes/@{partner:handle}/merge', [ConversationMergeController::class, 'store'])
->name('api-conversation-merge.store');
Route::post('remotes/@{partner:handle}/drop', [ConversationDropController::class, 'store'])
->name('api-conversation-drop.store');
});
// Remotes: the inbox and threads of the web's Remotes page, polled as often as it polls them...
Route::middleware('throttle:conversations')->group(function (): void {
Route::get('remotes', [ConversationController::class, 'index'])->name('api-conversation.index');
Route::get('remotes/@{partner:handle}/messages', [ConversationMessageController::class, 'index'])
->name('api-conversation-message.index');
Route::put('remotes/@{partner:handle}/read', [ConversationReadController::class, 'update'])
->name('api-conversation-read.update');
Route::get('remotes/orgs/{org}/messages', [OrgMessageController::class, 'index'])
->whereUuid('org')
->name('api-org-message.index');
Route::put('remotes/orgs/{org}/read', [OrgReadController::class, 'update'])
->whereUuid('org')
->name('api-org-read.update');
Route::get('remotes/messages/{message}/link-preview', [MessageLinkPreviewController::class, 'show'])
->whereNumber('message')
->name('api-message-link-preview.show');
});
// Remotes: saying the user is typing, as the web's composer does every few seconds...
Route::middleware('throttle:conversations')->group(function (): void {
Route::put('remotes/@{partner:handle}/typing', [ConversationTypingController::class, 'update'])
->name('api-conversation-typing.update');
Route::put('remotes/orgs/{org}/typing', [OrgTypingController::class, 'update'])
->whereUuid('org')
->name('api-org-typing.update');
});
// Remotes: pushing a message, as often as the web's composer may...
Route::post('remotes/@{partner:handle}/messages', [ConversationMessageController::class, 'store'])
->middleware([PreventPostingInTimeout::class, 'throttle:messages'])
->name('api-conversation-message.store');
Route::post('remotes/orgs/{org}/messages', [OrgMessageController::class, 'store'])
->whereUuid('org')
->middleware([PreventPostingInTimeout::class, 'throttle:messages'])
->name('api-org-message.store');
// Remotes: pinging the partner, as the web's composer does...
Route::post('remotes/@{partner:handle}/ping', [ConversationPingController::class, 'store'])
->middleware([PreventPostingInTimeout::class, 'throttle:pings'])
->name('api-conversation-ping.store');
Route::post('remotes/orgs/{org}/ping', [OrgPingController::class, 'store'])
->whereUuid('org')
->middleware([PreventPostingInTimeout::class, 'throttle:pings'])
->name('api-org-ping.store');
// Remote Calls: ringing, answering and ending a call, and checking in to an org's, polled as the web polls them...
Route::middleware('throttle:conversations')->group(function (): void {
Route::get('remotes/call', [CallController::class, 'show'])->name('api-call.show');
Route::get('remotes/@{partner:handle}/call', [ConversationCallController::class, 'show'])
->name('api-conversation-call.show');
Route::put('remotes/@{partner:handle}/call', [ConversationCallController::class, 'update'])
->name('api-conversation-call.update');
Route::delete('remotes/@{partner:handle}/call', [ConversationCallController::class, 'destroy'])
->name('api-conversation-call.destroy');
Route::put('remotes/orgs/{org}/call', [OrgCallController::class, 'update'])
->whereUuid('org')
->name('api-org-call.update');
Route::delete('remotes/orgs/{org}/call', [OrgCallController::class, 'destroy'])
->whereUuid('org')
->name('api-org-call.destroy');
});
// Remote Calls: starting or joining one, and the relay it goes through, as often as the web's Call may...
Route::middleware('throttle:messages')->group(function (): void {
Route::get('remotes/@{partner:handle}/call/ice-servers', [ConversationCallIceServerController::class, 'index'])
->name('api-conversation-call-ice-server.index');
Route::post('remotes/@{partner:handle}/call', [ConversationCallController::class, 'store'])
->middleware(PreventPostingInTimeout::class)
->name('api-conversation-call.store');
Route::get('remotes/orgs/{org}/call/ice-servers', [OrgCallIceServerController::class, 'index'])
->whereUuid('org')
->name('api-org-call-ice-server.index');
Route::post('remotes/orgs/{org}/call', [OrgCallController::class, 'store'])
->whereUuid('org')
->middleware(PreventPostingInTimeout::class)
->name('api-org-call.store');
});
// Remote Reactions...
Route::middleware('throttle:conversations')->group(function (): void {
Route::get('remotes/reactions', [MessageReactionController::class, 'index'])->name('api-message-reaction.index');
Route::post('remotes/messages/{message}/reactions', [MessageReactionController::class, 'store'])
->whereNumber('message')
->name('api-message-reaction.store');
Route::delete('remotes/messages/{message}/reactions', [MessageReactionController::class, 'destroy'])
->whereNumber('message')
->name('api-message-reaction.destroy');
});
// Remote Pins: an org's maintainers pinning and unpinning messages for everyone in it...
Route::middleware('throttle:pins')->group(function (): void {
Route::put('remotes/messages/{message}/pin', [MessagePinController::class, 'update'])
->whereNumber('message')
->middleware(PreventPostingInTimeout::class)
->name('api-message-pin.update');
Route::delete('remotes/messages/{message}/pin', [MessagePinController::class, 'destroy'])
->whereNumber('message')
->name('api-message-pin.destroy');
});
// Notifications...
Route::get('notifications', [NotificationController::class, 'index'])->name('api-notification.index');
Route::get('notifications/{notification}/group', [NotificationGroupController::class, 'show'])->name('api-notification-group.show');
// Remotes: finding people to push to, and starting an org, as the web's New remote and New org do...
Route::middleware('throttle:conversations')->group(function (): void {
Route::get('remotes/candidates', [RemoteCandidateController::class, 'index'])->name('api-remote-candidate.index');
Route::post('remotes/orgs', [OrgController::class, 'store'])->middleware([PreventPostingInTimeout::class, 'throttle:messages'])->name('api-org.store');
});
// Remotes: renaming an org and managing its members, as the web's org settings do...
Route::middleware('throttle:conversations')->group(function (): void {
Route::put('remotes/orgs/{org}', [OrgController::class, 'update'])
->whereUuid('org')
->middleware(PreventPostingInTimeout::class)
->name('api-org.update');
Route::post('remotes/orgs/{org}/members', [OrgMemberController::class, 'store'])
->whereUuid('org')
->middleware([PreventPostingInTimeout::class, 'throttle:messages'])
->name('api-org-member.store');
Route::put('remotes/orgs/{org}/members/{member:handle}', [OrgMemberController::class, 'update'])
->whereUuid('org')
->withoutScopedBindings()
->name('api-org-member.update');
Route::delete('remotes/orgs/{org}/members/{member:handle}', [OrgMemberController::class, 'destroy'])
->whereUuid('org')
->withoutScopedBindings()
->name('api-org-member.destroy');
});
});
});