2.6 KiB
2.6 KiB
Agent 3 — Batch 2 Implementation Report
Scope
Frontend-only update for Batch 2: wire the "Report Content directly" UI to call a web API instead of opening a Telegram deep link, and fix the hardcoded bot username.
Files Changed
1. frontend/src/lib/api.js
- Change: Exported
API_BASEso it can be imported byHome.svelte. - Before:
const API_BASE = "http://127.0.0.1:8090"; - After:
export const API_BASE = "http://127.0.0.1:8090";
2. frontend/src/routes/Home.svelte
- Import: Added
API_BASEto the import from../lib/api.js. - State: Added
reportStatusandreportStatusIsErrorreactive state variables. - Function: Added
submitDirectReport()async function that:- Validates
reportCxidis non-empty. - Sends
POST ${API_BASE}/api/content/${encodeURIComponent(reportCxid.trim())}/reportwith JSON body{ reason: "Direct web report" }. - On success: sets
reportStatus = "Report submitted successfully.", clearsreportCxid. - On error: sets
reportStatusto the error message andreportStatusIsError = true.
- Validates
- Template — "Report Content via Telegram":
- Replaced hardcoded
harmfulmeowbotwith${BOT_USERNAME}. - Kept deep-link parameter
?start=submitas before.
- Replaced hardcoded
- Template — "Report Content directly":
- Removed the
<a>wrapper around the Submit button. - Changed the button to
onclick={submitDirectReport}. - Added conditional status paragraph below the input row that shows green text on success and red (
var(--retro-danger)) on error.
- Removed the
- Styling: Added
.report-statusCSS rule inside the existing<style>block.
Build Result
> cgcx-frontend@0.1.0 build
> vite build
✓ built in 3.51s
Result: PASS
Open Risks / Follow-up
- Backend endpoint missing: The server currently has no
POST /api/content/:cxid/reportroute. The frontend will receive404 Not Founduntil the backend endpoint is added incrates/cgcx-server/src/main.rs. - Backend tasks still pending (per plan):
- Add
reqwesttocrates/cgcx-server/Cargo.toml. - Implement
POST /api/content/:cxid/reporthandler (DB insert viaReportRepo, then forward notification to Telegram review groups via Bot API HTTP call).
- Add
- Path assumption: The frontend uses
/api/content/:cxid/reportas suggested in the task instructions. If the backend implementation chooses a different path (e.g.,/api/reportwith body fields), the frontend fetch URL will need to be updated to match.
Recommended Next Step
Implement the backend POST /api/content/:cxid/report endpoint so the frontend submission actually works end-to-end.