Repository navigation
feat(mobile): create and copy webhook automations #15087
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
220e566
feat(mobile): create and copy webhook automations
juliusmarminge 292f742
feat(mobile): webhook tasks are editable again
juliusmarminge 284cf19
fix(mobile): saving keeps the current webhook signature and copies a …
juliusmarminge 8d93756
fix(mobile): only a full webhook URL can be copied
juliusmarminge 29e8e1a
feat(mobile,client-runtime): webhook URLs work without T3 Connect and…
juliusmarminge 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
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,36 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { webhookAddress } from "./webhookAddress.ts"; | ||
|
|
||
| const path = "/api/hooks/scheduled-task%3Ahook/token"; | ||
| const endpoint = (url: string | null) => ({ path, url, hasSecret: false }); | ||
|
|
||
| describe("webhookAddress", () => { | ||
| it("uses the T3 Connect URL when the server has one", () => { | ||
| expect(webhookAddress(endpoint("https://relay.t3.codes/v1/hooks/k/t/x"), null)).toEqual({ | ||
| address: "https://relay.t3.codes/v1/hooks/k/t/x", | ||
| copyable: true, | ||
| note: null, | ||
| }); | ||
| }); | ||
|
|
||
| it("builds a direct URL on the environment's address without T3 Connect", () => { | ||
| const result = webhookAddress(endpoint(null), "https://mac.tail1234.ts.net/"); | ||
| expect(result.address).toBe(`https://mac.tail1234.ts.net${path}`); | ||
| expect(result.copyable).toBe(true); | ||
| expect(result.note).toContain("Tailscale"); | ||
| }); | ||
|
|
||
| it("says only this computer can call a loopback address", () => { | ||
| const result = webhookAddress(endpoint(null), "http://127.0.0.1:3773/"); | ||
| expect(result.copyable).toBe(true); | ||
| expect(result.note).toContain("Only this computer"); | ||
| }); | ||
|
|
||
| it("falls back to the path when the address is unknown", () => { | ||
| expect(webhookAddress(endpoint(null), null)).toMatchObject({ | ||
| address: path, | ||
| copyable: false, | ||
| }); | ||
| }); | ||
| }); |
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,40 @@ | ||
| import type { ScheduledTaskWebhookEndpoint } from "@t3tools/contracts"; | ||
| import { isLocalLoopbackHost } from "@t3tools/shared/hostClassification"; | ||
|
|
||
| /** | ||
| * Where a sender can call a webhook task, as a client shows it. With T3 | ||
| * Connect the server returns a public URL; without it the path is resolved on | ||
| * the address this client reaches the environment at. | ||
| */ | ||
| export interface WebhookAddress { | ||
| /** The URL to give a sender, or the bare path when no address is known. */ | ||
| readonly address: string; | ||
| /** Whether `address` is a full URL a sender can call. */ | ||
| readonly copyable: boolean; | ||
| /** One line on who can reach `address`; null for a T3 Connect URL. */ | ||
| readonly note: string | null; | ||
| } | ||
|
|
||
| export function webhookAddress( | ||
| endpoint: ScheduledTaskWebhookEndpoint, | ||
| httpBaseUrl: string | null, | ||
| ): WebhookAddress { | ||
| if (endpoint.url !== null) { | ||
| return { address: endpoint.url, copyable: true, note: null }; | ||
| } | ||
| if (httpBaseUrl === null) { | ||
| return { | ||
| address: endpoint.path, | ||
| copyable: false, | ||
| note: "Link this environment to T3 Connect for a public URL.", | ||
| }; | ||
| } | ||
| const url = new URL(endpoint.path, httpBaseUrl); | ||
| return { | ||
| address: url.href, | ||
| copyable: true, | ||
| note: isLocalLoopbackHost(url.hostname) | ||
| ? "Only this computer can call this address. Link T3 Connect for a public URL." | ||
| : "Works wherever this environment's address is reachable, for example over Tailscale or your own proxy. Link T3 Connect for a public URL.", | ||
| }; | ||
| } |
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.
🟡 Medium
settings/SettingsScheduledTasksRouteScreen.tsx:918The signature status shown in
WebhookScheduleDetailscan be stale: changes made on desktop/web while this editor is open are not reflected, so the screen reports an incorrect webhook signature configuration.signatureConfiguredis read from the form-open-timedraft.schedulewhiletaskcomes from the live subscription; derive the status from the passed live webhook task instead.🚀 Reply "fix it for me" or copy this AI Prompt for your agent: