Skip to content

feat(outbound): add glucodroid.cloud destination preset - #38

Merged
robster7674 merged 1 commit into
glucodroidfrom
feat/glucodroid-cloud-preset
Jun 8, 2026
Merged

feat(outbound): add glucodroid.cloud destination preset#38
robster7674 merged 1 commit into
glucodroidfrom
feat/glucodroid-cloud-preset

Conversation

@robster7674

Copy link
Copy Markdown
Owner

Summary

Adds a first-class glucodroid.cloud preset to the outbound API destination picker.

  • Subdomain + token fields only — no raw URL, headers, or template editor shown (they don't apply to this preset)
  • URL resolution: https://{subdomain}.glucodroid.cloud/api/v1/ingest?token=…
  • Listed first in the preset picker
  • minIntervalMinutes defaults to 0 (the cloud service handles its own deduplication)
  • Subdomain cleared when switching away from this preset to avoid stale data leaking into another preset's URL field

Test plan

  • Add a new destination, select glucodroid.cloud preset — verify only subdomain and token fields are shown
  • Enter a subdomain and token, save — verify the resolved URL is https://<subdomain>.glucodroid.cloud/api/v1/ingest?token=<token>
  • Send a test reading — verify it reaches the glucodroid.cloud ingest endpoint
  • Switch preset to another type — verify the subdomain field is cleared
  • Verify other presets (Telegram, VK, custom JSON) are unaffected

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a first-class glucodroid.cloud destination preset, surfacing only subdomain and token fields in the UI and building the ingest URL as https://{subdomain}.glucodroid.cloud/api/v1/ingest?token={encoded_token}.

  • Token is percent-encoded via Uri.encode() before interpolation into the query string, fixing malformed URLs for tokens containing +, &, =, or #.
  • The subdomain OutlinedTextField is now composed before the shared token field, matching the URL structure; the URL/headers/template sections are hidden for this preset.
  • createDestination correctly sets minIntervalMinutes = 0 for the glucodroid preset, but decodeDestinations still falls back to the global default (5 minutes) when deserializing a stored entry that lacks this field.

Confidence Score: 5/5

Safe to merge; the core URL-building, field ordering, and preset-switching logic are all correct.

The token-encoding fix and field-reordering fix are both clean and correctly implemented. The only remaining gap is in decodeDestinations, where a missing minIntervalMinutes field in stored JSON would restore a 5-minute throttle for glucodroid_cloud instead of 0 — a non-happy-path edge case that does not affect normal saves or new destinations.

Common/src/main/java/tk/glucodata/OutboundApiSettings.kt — specifically the decodeDestinations fallback for minIntervalMinutes.

Important Files Changed

Filename Overview
Common/src/main/java/tk/glucodata/OutboundApiSettings.kt Adds Uri.encode() for the ingest token in resolvedUrl(), and wires glucodroid_cloud into createDestination with minIntervalMinutes=0. decodeDestinations still falls back to DEFAULT_MIN_INTERVAL_MINUTES (5) for glucodroid_cloud when the field is absent from stored JSON.
Common/src/mobile/java/tk/glucodata/ui/OutboundApiSettingsScreen.kt Moves the glucodroid subdomain field above the shared token field and gates URL/headers/template fields behind !isGlucodroid; field ordering and visibility are now correct.

Sequence Diagram

sequenceDiagram
    participant UI as OutboundApiSettingsScreen
    participant Settings as OutboundApiSettings
    participant Server as glucodroid.cloud

    UI->>Settings: createDestination(PRESET_GLUCODROID_CLOUD)
    Settings-->>UI: "Destination(url="", token="", minIntervalMinutes=0)"

    UI->>UI: "User enters subdomain → destination.copy(url=subdomain.trim())"
    UI->>UI: "User enters token → destination.copy(token=token)"
    UI->>Settings: save(config)

    UI->>Settings: resolvedUrl()
    Settings->>Settings: Uri.encode(token.trim())
    Settings-->>UI: "https://{subdomain}.glucodroid.cloud/api/v1/ingest?token={encoded}"

    UI->>Server: POST resolvedUrl()
    Server-->>UI: 200 OK

    UI->>Settings: withPreset(otherPreset)
    Note over Settings: oldPreset==PRESET_GLUCODROID_CLOUD → url reset to defaultUrl(newPreset)
Loading

Reviews (3): Last reviewed commit: "fix(outbound): URL-encode token in gluco..." | Re-trigger Greptile

Comment thread Common/src/main/java/tk/glucodata/OutboundApiSettings.kt Outdated
Comment thread Common/src/mobile/java/tk/glucodata/ui/OutboundApiSettingsScreen.kt Outdated
Comment thread Common/src/main/java/tk/glucodata/OutboundApiSettings.kt
…in before token

- Uri.encode() the ingest token so characters like +, &, =, # in
  base64-style tokens don't produce malformed query strings.
- Move the subdomain field above the token field in the UI so the
  order matches the URL shape (subdomain → token) and users fill
  in the account identifier first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@robster7674
robster7674 force-pushed the feat/glucodroid-cloud-preset branch from 53a8091 to 4e6a6c3 Compare June 8, 2026 17:20
@robster7674
robster7674 merged commit 3b3484d into glucodroid Jun 8, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant