sync: dev to extern-contrib#972
Conversation
Agent-Logs-Url: https://github.com/XMOJ-Script-dev/XMOJ-Script/sessions/606d7c42-f0ad-4d97-80ae-b8d92c2d6725 Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
…1-again Migrate XMOJ-BBS client endpoints to `/v1` routes
Deploying xmoj-script-dev-channel with
|
| Latest commit: |
45c56a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4e9555a6.xmoj-script-dev-channel.pages.dev |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAligns extern-contrib with dev by bumping the script/package version and routing all API, WebSocket, and asset/image requests through the new /v1 backend paths. Sequence diagram for image upload using v1 backendsequenceDiagram
actor User
participant Browser
participant XMOJUserScript
participant BackendAPI_v1 as BackendAPI_v1
participant AssetsService_v1 as AssetsService_v1
User->>Browser: Select image to upload
Browser->>XMOJUserScript: change event with File
XMOJUserScript->>XMOJUserScript: FileReader.readAsDataURL
XMOJUserScript->>BackendAPI_v1: POST https://api.xmoj-bbs.me/v1/UploadImage
activate BackendAPI_v1
BackendAPI_v1-->>XMOJUserScript: { Success, Data.ImageID }
deactivate BackendAPI_v1
XMOJUserScript->>XMOJUserScript: Build markdown
Note over XMOJUserScript: 
XMOJUserScript->>Browser: Update textarea value
Browser->>AssetsService_v1: GET https://assets.xmoj-bbs.me/v1/GetImage?ImageID=ImageID
AssetsService_v1-->>Browser: Image content
Browser-->>User: Render image in markdown preview
Architecture diagram for script routing to v1 servicesflowchart LR
subgraph Client
U[User]
B[Browser]
S[XMOJUserScript]
end
subgraph ProdBackend
APIv1[api.xmoj-bbs.me/v1]
WSv1[api.xmoj-bbs.me/v1/ws/notifications]
ASSETv1[assets.xmoj-bbs.me/v1/GetImage]
end
subgraph LocalDebug
APIv1_local[127.0.0.1:8787/v1]
WSv1_local[ws://127.0.0.1:8787/v1/ws/notifications]
end
U --> B --> S
S -->|HTTP API requests| APIv1
S -->|WebSocket notifications| WSv1
S -->|Markdown image URLs| ASSETv1
S -->|SuperDebug HTTP API| APIv1_local
S -->|SuperDebug WebSocket| WSv1_local
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
/v1/API and asset path segments are now hardcoded in multiple places (user script, messages.html, markdown insertions); consider centralizing these into shared constants/helpers so future version bumps only require a single change point. - The various image URL templates for markdown insertion are duplicated across several content-editing code paths; it may be worth extracting a small utility to generate the asset URL to reduce the risk of inconsistencies on future changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `/v1/` API and asset path segments are now hardcoded in multiple places (user script, messages.html, markdown insertions); consider centralizing these into shared constants/helpers so future version bumps only require a single change point.
- The various image URL templates for markdown insertion are duplicated across several content-editing code paths; it may be worth extracting a small utility to generate the asset URL to reduce the risk of inconsistencies on future changes.
## Individual Comments
### Comment 1
<location path="XMOJ.user.js" line_range="646" />
<code_context>
}
- let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/ws/notifications?SessionID=" + Session;
+ let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/v1/ws/notifications?SessionID=" + Session;
if (UtilityEnabled("DebugMode")) {
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider URL-encoding `Session` when building the WebSocket URL.
If `Session` can contain reserved URL characters (like `?` or `&`), concatenating it directly into the query string may produce an invalid URL. Using `encodeURIComponent(Session)` will make the URL construction robust while preserving current behavior for simple tokens.
```suggestion
let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/v1/ws/notifications?SessionID=" + encodeURIComponent(Session);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| } | ||
|
|
||
| let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/ws/notifications?SessionID=" + Session; | ||
| let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/v1/ws/notifications?SessionID=" + Session; |
There was a problem hiding this comment.
suggestion (bug_risk): Consider URL-encoding Session when building the WebSocket URL.
If Session can contain reserved URL characters (like ? or &), concatenating it directly into the query string may produce an invalid URL. Using encodeURIComponent(Session) will make the URL construction robust while preserving current behavior for simple tokens.
| let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/v1/ws/notifications?SessionID=" + Session; | |
| let wsUrl = (UtilityEnabled("SuperDebug") ? "ws://127.0.0.1:8787" : "wss://api.xmoj-bbs.me") + "/v1/ws/notifications?SessionID=" + encodeURIComponent(Session); |
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Update.json">
<violation number="1" location="Update.json:3551">
P3: Fix the malformed release-note description to include the intended route path (likely `/v1`).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Signed-off-by: zsTree <wa2025666@gmail.com>
Reverts the API route changes from #969 that added /v1/ prefixes to all backend endpoints, while preserving the 3.4.3 version bump. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion Revert /v1 endpoint migration
Signed-off-by: zsTree <wa2025666@gmail.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
Signed-off-by: zsTree <wa2025666@gmail.com>
Fix loginpage.php Loop
sync-branches: New code has just landed in dev, so let's bring extern-contrib up to speed!
Summary by Sourcery
Bug Fixes:
Summary by cubic
Syncs
extern-contribwith dev by reverting the/v1endpoint migration and fixing the loginpage.php redirect loop. Bumps to 3.4.5 (prerelease) and aligns API, WebSocket, and asset routes with the backend.Bug Fixes
loginpage.phpresponse and gating AutoLogin/profile redirects.Refactors
/v1paths for API, image assets, and notifications WebSocket.3.4.5inXMOJ.user.jsandpackage.json; updateUpdate.jsonwith prerelease entries for3.4.3–3.4.5.Written for commit 45c56a2. Summary will update on new commits.