Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a02d054cc | |||
| dbd4de8e61 | |||
| a0bb229173 | |||
| c86c602294 | |||
| aa39b6a5be | |||
| 8cf1e91b2b | |||
| f068e15398 | |||
| 559d17d1f2 | |||
| ea72050202 | |||
| 88194b17c4 | |||
| 2b45b11ea8 | |||
| b3b5ff495d | |||
| 9512dedec1 | |||
| 8bbe2a0ff0 | |||
| c2fb3165f4 | |||
| 0c26e2402b | |||
| 88e7faaafb | |||
| 1d37284c25 | |||
| b1b41ca5e1 | |||
| e10cb22811 | |||
| 2631e6ce4a | |||
| 239640975f | |||
| ed408c4044 | |||
| 9aeedb1a53 | |||
| 59846fc1e4 | |||
| 944ae4074e | |||
| 549bf842d0 | |||
| 83c05731ed | |||
| 5d8f420882 | |||
| 074742ddb4 | |||
| f9b1e16e3a | |||
| f9edd8c069 | |||
| 7e1c0b822b | |||
| f61b33ff81 | |||
| ed50815902 | |||
| b4e2f97dba | |||
| 53f8c6b2ef | |||
| d1022d7c2a | |||
| 15f9f6ae07 | |||
| c803991cda | |||
| a502cd8fd4 | |||
| a593f04d7f | |||
| 6b7dc2addd | |||
| 8336ca5d87 | |||
| 85f9c21f4c | |||
| 92af2e21b1 | |||
| 1e22daead3 | |||
| 9e70884a16 | |||
| b6d4614881 | |||
| 0b645fe765 | |||
| f6f63ecd2b | |||
| f30ddb1323 | |||
| 5ca5e018ca | |||
| 3002626ac4 | |||
| 4ed2e5bfd0 | |||
| aa80e354c9 | |||
| cf2f1c96a3 | |||
| 40f8d193ff | |||
| d8b4defaff | |||
| 722eab8e94 | |||
| 19ac68d058 | |||
| 3a04eff42b | |||
| 59f6a40882 | |||
| 5a7d4dc57e | |||
| 89f8381e2d | |||
| eb5b7d55a4 | |||
| 7d67d6f360 | |||
| 08dfc4e400 | |||
| cbfbcb2627 | |||
| ca7a9e30f1 | |||
| 10a702f732 | |||
| af961d805e | |||
| 7f2a58599d | |||
| 67ce6bbfd9 | |||
| c0686d4ca3 | |||
| 74a1db8392 | |||
| 5cc9d76394 | |||
| 3aa1ca3ead | |||
| 3ed66f3d43 | |||
| a5c3b25cc0 | |||
| 17c09edc4f | |||
| d0da35e816 | |||
| 31cb295a24 | |||
| ecb26cb731 | |||
| cb8aeddde6 | |||
| 33dc63b94c | |||
| 48a99d58ee | |||
| c80a36bacb | |||
| 65de4efb0d | |||
| b8ae43e250 | |||
| 82ddf914e4 | |||
| f4437c5e1d |
@@ -1,8 +0,0 @@
|
||||
.git
|
||||
node_modules
|
||||
web/dist
|
||||
certs
|
||||
*.zip
|
||||
dumpster-server
|
||||
.env
|
||||
.env.local
|
||||
@@ -1,23 +1,25 @@
|
||||
# dumpsterChat Environment Configuration
|
||||
# Copy this file to .env and fill in your values.
|
||||
|
||||
# Server
|
||||
DUMPSTER_HOST=dumpster.dustin.coffee
|
||||
DUMPSTER_SECRET=generate-a-random-secret-here
|
||||
|
||||
# Database
|
||||
# App
|
||||
DUMPSTER_HOST=localhost
|
||||
DUMPSTER_PORT=8080
|
||||
DUMPSTER_SECRET=*** Database
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_USER=dumpster
|
||||
POSTGRES_PASSWORD=generate-a-random-password-here
|
||||
POSTGRES_DB=dumpster
|
||||
|
||||
# MinIO (optional — omit for local filesystem)
|
||||
MINIO_ENDPOINT=
|
||||
MINIO_ACCESS_KEY=
|
||||
MINIO_SECRET_KEY=
|
||||
|
||||
# LiveKit (WebRTC / voice)
|
||||
LIVEKIT_API_KEY=generate-a-random-key-here
|
||||
LIVEKIT_API_SECRET=generate-a-random-secret-here
|
||||
|
||||
# Giphy (optional — for GIF search)
|
||||
GIPHY_API_KEY=
|
||||
POSTGRES_PASSWORD=dumpster
|
||||
POSTGRES_SSLMODE=disable
|
||||
# Valkey
|
||||
VALKEY_URL=redis://localhost:***@example.com
|
||||
# MinIO
|
||||
MINIO_ENDPOINT=minio:9000
|
||||
MINIO_ACCESS_KEY=<generated>
|
||||
MINIO_SECRET_KEY=<gener...n
|
||||
# LiveKit
|
||||
LIVEKIT_URL=wss://livekit.your.domain
|
||||
LIVEKIT_API_KEY=<generated>
|
||||
LIVEKIT_API_SECRET=<gener...n
|
||||
# Web Push
|
||||
VAPID_PUBLIC_KEY=<generated>
|
||||
VAPID_PRIVATE_KEY=<generated>
|
||||
VAPID_SUBJECT=admin@your.domain
|
||||
# Integrations
|
||||
GIPHY_API_KEY=your_giphy_api_key_here
|
||||
|
||||
@@ -11,22 +11,9 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with: { node-version: 20 }
|
||||
- name: Cache npm
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('web/package-lock.json') }}
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Cache Rust target and registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
web/src-tauri/target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('web/src-tauri/Cargo.lock') }}
|
||||
- name: Install system deps
|
||||
run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libappindicator3-dev librsvg2-dev patchelf rpm
|
||||
run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
- name: Build frontend
|
||||
run: cd web && npm ci && npm run build
|
||||
- name: Build Tauri bundles
|
||||
@@ -34,7 +21,7 @@ jobs:
|
||||
NO_STRIP: "true"
|
||||
run: cd web && npx tauri build
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-bundles
|
||||
path: |
|
||||
@@ -48,33 +35,13 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with: { node-version: 20 }
|
||||
- name: Cache npm
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-npm-${{ hashFiles('web/package-lock.json') }}
|
||||
- name: Install Rust
|
||||
run: |
|
||||
curl.exe -sLo rustup-init.exe https://win.rustup.rs/x86_64
|
||||
rustup-init.exe -y --default-toolchain stable --profile minimal
|
||||
set PATH=%USERPROFILE%\.cargo\bin;%PATH%
|
||||
rustc --version
|
||||
shell: cmd
|
||||
- name: Cache Rust target and registry
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: |
|
||||
web/src-tauri
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Build frontend
|
||||
run: cd web && npm ci && npm run build
|
||||
shell: cmd
|
||||
run: cd web; npm ci; npm run build
|
||||
- name: Build Tauri bundles
|
||||
env:
|
||||
CI: "true"
|
||||
run: cd web && set PATH=%USERPROFILE%\.cargo\bin;%PATH% && npx tauri build
|
||||
shell: cmd
|
||||
run: cd web; npx tauri build
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-bundles
|
||||
path: |
|
||||
@@ -85,16 +52,13 @@ jobs:
|
||||
needs: [build-linux, build-windows]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
- name: Create release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: actions/gitea-release-action@v3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref_name }}
|
||||
files: |
|
||||
linux-bundles/**/*.AppImage
|
||||
linux-bundles/**/*.deb
|
||||
linux-bundles/**/*.rpm
|
||||
windows-bundles/**/*.msi
|
||||
windows-bundles/**/*.exe
|
||||
linux-bundles/*
|
||||
windows-bundles/*
|
||||
|
||||
@@ -41,12 +41,3 @@ minio_data/
|
||||
/migrate
|
||||
/dumpster-server
|
||||
keygen
|
||||
steamfree
|
||||
|
||||
# Tauri Android keystore (contains signing passwords)
|
||||
web/src-tauri/gen/android/keystore.properties
|
||||
|
||||
# Secrets and certificates
|
||||
/certs/
|
||||
cookie.txt
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## vs Discord, Guilded (historical), TeamSpeak 6, Fluxer
|
||||
|
||||
Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of every row).
|
||||
Compiled 2026-06-30. Updated through Phase 7 completion.
|
||||
|
||||
---
|
||||
|
||||
@@ -21,23 +21,22 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
|
||||
| Feature | dumpsterChat | Discord | Guilded | TeamSpeak 6 | Fluxer |
|
||||
|---------|:------------:|:-------:|:-------:|:-----------:|:------:|
|
||||
| Text channels | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Direct messages | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Markdown support | ✅ | ✅ full | ✅ full | ❌ basic | ✅ full |
|
||||
| Reactions | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Replies | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Threads | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Forum channels | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Pinned messages | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Message search | ✅ | ✅ full | ✅ | ❌ | ✅ Meilisearch |
|
||||
| Edit / delete messages | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Rich embeds / link unfurling | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| File uploads | ⚠️ MinIO | ✅ | ✅ | ✅ | ✅ S3-backed |
|
||||
| GIF picker (Giphy) | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Typing indicators | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Message history (pagination) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Read receipts | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| @everyone / @channel | ✅ (perm gated) | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Text channels | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
|| Direct messages | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Markdown support | ✅ | ✅ full | ✅ full | ❌ basic | ✅ full |
|
||||
|| Reactions | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Replies | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Threads | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
|| Forum channels | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
|| Pinned messages | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
|| Message search | ✅ | ✅ full | ✅ | ❌ | ✅ Meilisearch |
|
||||
|| Edit / delete messages | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Rich embeds / link unfurling | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| File uploads | ⚠️ MinIO | ✅ | ✅ | ✅ | ✅ S3-backed |
|
||||
|| GIF picker (Giphy) | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Typing indicators | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|| Message history (pagination) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
|| Read receipts | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
|
||||
---
|
||||
|
||||
@@ -69,7 +68,7 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
| Badges | ❌ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Usernames + discriminators | ✅ | ⚠️ handles | ❌ | ✅ UID | ✅ #0000 |
|
||||
| Friend requests | ❌ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Block list | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
|| Block list | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| Activity / game status | ❌ | ✅ | ✅ | ❌ | ❌ |
|
||||
|
||||
---
|
||||
@@ -81,12 +80,11 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
| Roles | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Hierarchical roles | ⚠️ basic | ✅ | ✅ | ✅ | ✅ |
|
||||
| Permission bitflags | ✅ | ✅ | ✅ | ✅ granular | ✅ |
|
||||
| Per-channel permission overrides | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
|| Per-channel permission overrides | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| @everyone default role | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Role colors | ⚠️ DB ready | ✅ | ✅ | ❌ | ✅ |
|
||||
| Role icons | ❌ | ✅ Nitro | ❌ | ❌ | ❌ |
|
||||
| Administrator bypass | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Client-side permission gates | ✅ (user roles + @everyone) | ✅ | ✅ | ✅ | ✅ |
|
||||
|
||||
### dumpsterChat Permissions (current)
|
||||
|
||||
@@ -125,7 +123,7 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
| Server invites | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Vanity URLs | ❌ | ✅ Nitro | ❌ | ❌ | ❌ |
|
||||
| Webhooks | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Bots / API | ⚠️ store + runner | ✅ huge | ✅ Flow Bots | ❌ plugins | 🔄 |
|
||||
| Bots / API | ⚠️ slash cmds | ✅ huge | ✅ Flow Bots | ❌ plugins | 🔄 |
|
||||
| Server templates | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Server discovery | ❌ | ✅ | ✅ | ✅ | 🔄 |
|
||||
| Server analytics | ❌ | ✅ | ✅ | ❌ | ❌ |
|
||||
@@ -141,10 +139,10 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
| Desktop notifications | ⚠️ possible via SW | ✅ | ✅ | ✅ | ✅ |
|
||||
| Web push notifications | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| @mention push | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Channel-wide push (@everyone/@channel) | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Channel-wide push | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| Email notifications | ❌ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Mobile apps | ❌ (PWA is target) | ✅ iOS/Android | ✅ | ✅ | 🔄 Flutter alpha |
|
||||
| Per-channel notification settings | ⚠️ partial | ✅ | ✅ | ✅ | ✅ |
|
||||
| Mobile apps | ❌ | ✅ iOS/Android | ✅ | ✅ | 🔄 Flutter alpha |
|
||||
| Per-channel notification settings | ❌ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Do Not Disturb schedule | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
|
||||
---
|
||||
@@ -158,7 +156,6 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
| Slash commands | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Command options / JSON schema | ✅ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Bot mentions | ✅ | ✅ | ❌ | ❌ | 🔄 |
|
||||
| Built-in bot runner (anonConfess, leaderboard, steamfree) | ✅ | ❌ | ⚠️ | ❌ | ❌ |
|
||||
| Third-party integrations (Twitch, YouTube, GitHub) | ❌ | ✅ | ✅ | ❌ | 🔄 |
|
||||
| Webhook-driven bots | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
|
||||
@@ -171,11 +168,40 @@ Compiled 2026-06-30. **Status refreshed 2026-07-15** (not a full re-audit of eve
|
||||
- Terminal/Gruvbox aesthetic
|
||||
- WebAuthn / passkey auth
|
||||
- LiveKit voice integration
|
||||
- Built-in bot store + managed runner
|
||||
- PWA-first mobile (no native app planned)
|
||||
- Built-in webhook execution for simple integrations
|
||||
|
||||
### Discord / Guilded / TeamSpeak / Fluxer
|
||||
See historical notes in git history if needed. Not the product roadmap.
|
||||
### Discord
|
||||
- Massive network effect (200M+ MAU)
|
||||
- Nitro subscription perks (animated avatars, HD streaming, larger uploads)
|
||||
- Activities / embedded apps in voice channels
|
||||
- Server boosting tiers
|
||||
- Stage channels
|
||||
- Activities marketplace
|
||||
|
||||
### Guilded (historical)
|
||||
- Built-in calendar with RSVP
|
||||
- Scheduling + availability system
|
||||
- Docs / forms
|
||||
- Lists (task management)
|
||||
- Tournaments
|
||||
- Server Subs monetization
|
||||
- Server Groups (sub-servers)
|
||||
|
||||
### TeamSpeak 6
|
||||
- Self-hosted by design, free up to 32 slots
|
||||
- Granular Power/Needed Power permission system
|
||||
- Low resource client
|
||||
- Plugin ecosystem
|
||||
- Virtual servers
|
||||
- Whisper / poke / channel commander
|
||||
|
||||
### Fluxer
|
||||
- Fully open-source AGPL-3, Docker Compose deploy
|
||||
- No paywalls / license keys
|
||||
- Planned federation
|
||||
- Multi-backend switching
|
||||
- Erlang/OTP gateway for scale
|
||||
- 34 locales
|
||||
|
||||
---
|
||||
|
||||
@@ -184,37 +210,38 @@ See historical notes in git history if needed. Not the product roadmap.
|
||||
| Feature | dumpsterChat | Discord | Guilded | TeamSpeak 6 | Fluxer |
|
||||
|---------|:------------:|:-------:|:-------:|:-----------:|:------:|
|
||||
| Self-hostable | ✅ | ❌ | ❌ | ✅ | ✅ |
|
||||
| Open source | ⚠️ private self-host | ❌ | ❌ | ❌ | ✅ AGPL-3 |
|
||||
| Open source | ❌ | ❌ | ❌ | ❌ | ✅ AGPL-3 |
|
||||
| PWA support | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| REST API | ✅ | ✅ | ✅ | ❌ | ✅ |
|
||||
| WebSocket gateway | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Swagger docs | ✅ /docs | ✅ | ✅ | ❌ | ✅ |
|
||||
| Swagger docs | ✅ localhost | ✅ | ✅ | ❌ | ✅ |
|
||||
| Docker Compose | ✅ | ❌ | ❌ | ❌ | ✅ |
|
||||
|
||||
---
|
||||
|
||||
## Priority Recommendations (updated)
|
||||
## Priority Recommendations
|
||||
|
||||
**Do not treat this table as a todo list.** For a ~12 person friend server, parity rows are optional.
|
||||
### Critical gaps (would block most Discord/Guilded users)
|
||||
|
||||
### Actual next polish (product)
|
||||
1. Mobile PWA pain (input, notifs, safe areas)
|
||||
2. Role color UI / hierarchy polish
|
||||
3. Voice PTT / screen share only if voice is used
|
||||
4. Small slash toys (`/roll`, `/choose`) if wanted
|
||||
1. **Direct Messages** — no way to message users outside servers
|
||||
2. **Mobile app** — major adoption blocker
|
||||
3. **Voice push-to-talk** — important for voice-heavy communities
|
||||
4. **Email notifications** — needed for async engagement
|
||||
5. **Read receipts / unread state** — channel-level read tracking
|
||||
|
||||
### Real tech debt
|
||||
1. More tests on hot paths (permissions DB checker, bot auth)
|
||||
2. Keep client permission cache in sync after role edits (partially done)
|
||||
3. Deploy docs must name the real unit: `dumpster.service`
|
||||
### High-value next features
|
||||
|
||||
### Explicitly not critical
|
||||
- Friend requests (DMs already exist among members)
|
||||
- Native mobile apps
|
||||
- Discord bot ecosystem compatibility
|
||||
- Server discovery / monetization / federation
|
||||
- AutoMod / Flow Bots
|
||||
1. **Screen share** — LiveKit supports it; mostly frontend work
|
||||
2. **Custom emoji / reactions beyond unicode** — core Discord behavior
|
||||
3. **Server groups (sub-servers)** — channel organization
|
||||
4. **Do Not Disturb schedule** — notification control
|
||||
5. **Third-party integrations** — Twitch, YouTube, GitHub
|
||||
6. **Stage channels** — presentation-style voice
|
||||
|
||||
### Stale claims removed
|
||||
- ~~"Direct Messages missing"~~ — DMs exist
|
||||
- ~~"Mobile app is the only path"~~ — PWA is the target client
|
||||
### Nice-to-have differentiators
|
||||
|
||||
1. **No-code Flow Bots** (Guilded-style automations)
|
||||
2. **Server discovery / directory**
|
||||
3. **Activities / embedded games**
|
||||
4. **Federation** (Fluxer-style)
|
||||
5. **Server analytics**
|
||||
|
||||
@@ -18,16 +18,6 @@ build-tui:
|
||||
build-tauri:
|
||||
cd web && NODE_ENV=development NO_STRIP=true npx tauri build --bundles appimage,deb,rpm
|
||||
|
||||
# Build signed Android APK
|
||||
build-android:
|
||||
cd web && ANDROID_HOME=$(HOME)/Android/Sdk NDK_HOME=$(HOME)/Android/Sdk/ndk/27.2.12479018 JAVA_HOME=/usr/lib/jvm/java-17-openjdk npx tauri android build --apk
|
||||
@echo "APK: web/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk"
|
||||
|
||||
# Build signed Android AAB (Google Play bundle)
|
||||
build-android-aab:
|
||||
cd web && ANDROID_HOME=$(HOME)/Android/Sdk NDK_HOME=$(HOME)/Android/Sdk/ndk/27.2.12479018 JAVA_HOME=/usr/lib/jvm/java-17-openjdk npx tauri android build --aab
|
||||
@echo "AAB: web/src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab"
|
||||
|
||||
# Generate Swagger docs
|
||||
docs:
|
||||
~/go/bin/swag init -g cmd/server/main.go -o docs
|
||||
|
||||
@@ -58,13 +58,10 @@ For optional features, copy `.env.example` to `.env` and set Giphy, MinIO, LiveK
|
||||
- [x] Blocks (user-level blocking)
|
||||
- [x] Dark/light mode toggle
|
||||
- [x] Mobile-responsive layout (bottom nav, drawer)
|
||||
- [x] Bot framework (token auth, CRUD, WebSocket gateway, bot store)
|
||||
- [x] Built-in bot runner (server-managed bots, no SSH needed)
|
||||
- [x] Built-in bot: Steam Free Games (polls Steam API, auto-posts)
|
||||
- [x] Bot message badges (green name + BOT tag in chat)
|
||||
- [x] Bot framework (token auth, CRUD, WebSocket gateway)
|
||||
- [x] Slash commands (registration, autocomplete)
|
||||
- [x] Incoming webhooks (create, execute)
|
||||
- [x] Example bots (modbot, welcome bot, steamfree)
|
||||
- [x] Example bots (modbot, welcome bot)
|
||||
- [x] TUI client (Bubbletea, vim-style, voice support)
|
||||
- [x] Roles & permissions system
|
||||
- [x] Push notification backend (VAPID)
|
||||
@@ -100,7 +97,7 @@ dumpsterChat/
|
||||
│ ├── voice/ # LiveKit voice/video integration
|
||||
│ ├── reaction/ # Message reactions
|
||||
│ ├── invite/ # Server invite links
|
||||
│ ├── bot/ # Bot framework, auth, commands, runner
|
||||
│ ├── bot/ # Bot framework, auth, commands
|
||||
│ ├── webhook/ # Incoming webhooks
|
||||
│ ├── dm/ # Direct messages (conversations)
|
||||
│ ├── push/ # Push notification sender (VAPID)
|
||||
@@ -115,8 +112,7 @@ dumpsterChat/
|
||||
│ └── block/ # User blocking
|
||||
├── examples/ # Example bots
|
||||
│ ├── modbot/ # Moderation bot
|
||||
│ ├── welcome/ # Welcome message bot
|
||||
│ └── steamfree/ # Steam free games bot (standalone)
|
||||
│ └── welcome/ # Welcome message bot
|
||||
├── web/ # React frontend (PWA)
|
||||
│ ├── src/
|
||||
│ │ ├── components/ # Layout, ChatArea, LoginForm, UserSettings, GiphyPicker, VoiceChannel, VoicePanel, VoiceControls, TypingIndicator, ReactionBar, EmojiPicker, ReplyBar, MentionPopup, InviteModal, JoinServer, MobileNav, MobileDrawer, ThemeToggle, InstallPrompt, BotManager, CommandManager, SlashCommandPopup
|
||||
@@ -161,30 +157,6 @@ Users are prompted to enable notifications on login. On iOS, the prompt requires
|
||||
|
||||
Full documentation: [dumpsterChat wiki](ssh://git@git.dustin.coffee:2222/hobokenchicken/dumpsterChat.wiki.git)
|
||||
|
||||
## Production Deploy (SBC / 172.20.0.125)
|
||||
|
||||
App lives at `/opt/dumpsterChat`. systemd unit name is **`dumpster.service`** (not `dumpsterChat`).
|
||||
|
||||
```bash
|
||||
# Build locally
|
||||
CGO_ENABLED=0 go build -o dumpster-server ./cmd/server
|
||||
(cd web && npm run build)
|
||||
|
||||
# Ship binary + web assets
|
||||
scp dumpster-server root@172.20.0.125:/tmp/dumpster-server-new
|
||||
rsync -av --delete web/dist/ root@172.20.0.125:/opt/dumpsterChat/web/dist/
|
||||
|
||||
ssh root@172.20.0.125 '
|
||||
install -m 755 /tmp/dumpster-server-new /opt/dumpsterChat/dumpster-server
|
||||
systemctl restart dumpster
|
||||
systemctl is-active dumpster
|
||||
'
|
||||
```
|
||||
|
||||
Logs: `journalctl -u dumpster -f`
|
||||
Health: `curl -s http://127.0.0.1:8080/` (or your API health route)
|
||||
Public: Caddy → `dumpster.dustin.coffee` → `172.20.0.125:8080`
|
||||
|
||||
## License
|
||||
|
||||
AGPLv3
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDkTCCAxegAwIBAgISBQjShZO8+oxeU80iyTOUKHhdMAoGCCqGSM49BAMDMDMx
|
||||
CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQwwCgYDVQQDEwNZ
|
||||
RTIwHhcNMjYwNzA2MDEzMDM1WhcNMjYxMDA0MDEzMDM0WjAdMRswGQYDVQQDExJ0
|
||||
dXJuLmR1c3Rpbi5jb2ZmZWUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATB70bx
|
||||
IRjXyxdwR/3k56AkiFRKwApxq/h7xNXK5/I5xZ+5+HCLMHjEmFOIUtUj87DpcPHs
|
||||
rAfJZcH19gQIt7Xlo4ICHzCCAhswDgYDVR0PAQH/BAQDAgeAMBMGA1UdJQQMMAoG
|
||||
CCsGAQUFBwMBMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFE8HllwR3SN9Ay0rvVLX
|
||||
9mOsdJ0UMB8GA1UdIwQYMBaAFLlZ8o7PIvCG0zdI/3YUGLqC2FWHMDMGCCsGAQUF
|
||||
BwEBBCcwJTAjBggrBgEFBQcwAoYXaHR0cDovL3llMi5pLmxlbmNyLm9yZy8wHQYD
|
||||
VR0RBBYwFIISdHVybi5kdXN0aW4uY29mZmVlMBMGA1UdIAQMMAowCAYGZ4EMAQIB
|
||||
MC4GA1UdHwQnMCUwI6AhoB+GHWh0dHA6Ly95ZTIuYy5sZW5jci5vcmcvOTQuY3Js
|
||||
MIIBCwYKKwYBBAHWeQIEAgSB/ASB+QD3AHUAwjF+V0UZo0XufzjespBB68fCIVoi
|
||||
v3/Vta12mtkOUs0AAAGfNUH9yAAABAMARjBEAiBUIFA17umU+cAdlBJlkjhivt7h
|
||||
4f1HF7kdlQtt0hURaAIgRWAiqclKJy3QikfbGF7EFK3sNRyf/PZNBLtjJeieP1IA
|
||||
fgAm42RuWGkhI7w0P0ckNZs3ks0kWojYFdOTM/2ZGKtHIwAAAZ81QfvIAAgAAAUA
|
||||
JeWwugQDAEcwRQIhAJ9gzEj26/VOpYO0HkS2ZcItIhoBf7bDfzt9gpIK2RH2AiA2
|
||||
66DvuRKPYthZ4AFBXbVtSX4rf4aX2IvgQIWTudJMlDAKBggqhkjOPQQDAwNoADBl
|
||||
AjANu3rbmE/SqrfsMNGEv7rl+qvblv0btupKZ2qHg87079XD4gTh3Sqyl+Z4RnHq
|
||||
JkkCMQDI3q5ZQ6GVF3geVTbNvLlJ+R35eB+EIcoX0Cbs20S5k9N/SiWS2BlQzlUM
|
||||
QpPxaok=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICjDCCAhGgAwIBAgIQTfOxXdbAeExQfNN7WObxFTAKBggqhkjOPQQDAzAuMQsw
|
||||
CQYDVQQGEwJVUzENMAsGA1UEChMESVNSRzEQMA4GA1UEAxMHUm9vdCBZRTAeFw0y
|
||||
NTA5MDMwMDAwMDBaFw0yODA5MDIyMzU5NTlaMDMxCzAJBgNVBAYTAlVTMRYwFAYD
|
||||
VQQKEw1MZXQncyBFbmNyeXB0MQwwCgYDVQQDEwNZRTIwdjAQBgcqhkjOPQIBBgUr
|
||||
gQQAIgNiAARxmrQzkdbEEL3MqXt3dJQttYc47axkdDTHud5TPqM2z5uSD5cmk0Wr
|
||||
HlWXvnlvqBLqiB34kluxIbmMyAiq3/YD6e80/vV259K8XQIdjFXloYOa0mIU71f7
|
||||
HQ09PvYDlw+jge4wgeswDgYDVR0PAQH/BAQDAgGGMBMGA1UdJQQMMAoGCCsGAQUF
|
||||
BwMBMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFLlZ8o7PIvCG0zdI/3YU
|
||||
GLqC2FWHMB8GA1UdIwQYMBaAFKPIJlqOoUzQNWP8myPIOq5W809WMDIGCCsGAQUF
|
||||
BwEBBCYwJDAiBggrBgEFBQcwAoYWaHR0cDovL3llLmkubGVuY3Iub3JnLzATBgNV
|
||||
HSAEDDAKMAgGBmeBDAECATAnBgNVHR8EIDAeMBygGqAYhhZodHRwOi8veWUuYy5s
|
||||
ZW5jci5vcmcvMAoGCCqGSM49BAMDA2kAMGYCMQDIcnw5dcZLN9ffynXnnkLD/itS
|
||||
JEycJPb3sRkzeqBowup7vOsAwaqoCnNn/jh9wycCMQCJM6CPlaOC4pQYYbJtVPYb
|
||||
DKrIb2EKk5NpOpE6/XttQYZV/3gilB9l+Cc/DOVwmyg=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICpjCCAiugAwIBAgIRAIchZfw0tuX7qK3Vs3BftTowCgYIKoZIzj0EAwMwTzEL
|
||||
MAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNo
|
||||
IEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDIwHhcNMjYwNTEzMDAwMDAwWhcN
|
||||
MzIwOTAyMjM1OTU5WjAuMQswCQYDVQQGEwJVUzENMAsGA1UEChMESVNSRzEQMA4G
|
||||
A1UEAxMHUm9vdCBZRTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDwS/6vhrcVqcbBo
|
||||
+wgdI3fwn9x7DNJJOY/lTOti0vkwuRN87RhEhTH17E7XyFjWsPYhIPt/wzOqxTd2
|
||||
b+4ZJNy9ID04YywF9U5zasDVyGSNErVNtz8uSGh5izW87j77GaOB6zCB6DAOBgNV
|
||||
HQ8BAf8EBAMCAQYwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB
|
||||
/zAdBgNVHQ4EFgQUo8gmWo6hTNA1Y/ybI8g6rlbzT1YwHwYDVR0jBBgwFoAUfEKW
|
||||
rt5LSDv6kviejM9ti6lyN5UwMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzAChhZo
|
||||
dHRwOi8veDIuaS5sZW5jci5vcmcvMBMGA1UdIAQMMAowCAYGZ4EMAQIBMCcGA1Ud
|
||||
HwQgMB4wHKAaoBiGFmh0dHA6Ly94Mi5jLmxlbmNyLm9yZy8wCgYIKoZIzj0EAwMD
|
||||
aQAwZgIxAMU19WCtmxVND8UHBZRoma49Z7jPs64Dma0eTu1OChVbB/2J7GV3nvYK
|
||||
Ax54uk1G9QIxAO0miLVJu8PLNiXXXkiE/gsK3CTRTF/aeo4bMX42Zw40csRU6AC2
|
||||
6hSW1/IWaas6dg==
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEcDCCAligAwIBAgIQbI8dxyfHEX97r4U6yYD5zTANBgkqhkiG9w0BAQsFADBP
|
||||
MQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFy
|
||||
Y2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMTAeFw0yNjA1MTMwMDAwMDBa
|
||||
Fw0zMjA5MDIyMzU5NTlaME8xCzAJBgNVBAYTAlVTMSkwJwYDVQQKEyBJbnRlcm5l
|
||||
dCBTZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNSRyBSb290IFgy
|
||||
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0H
|
||||
ttwW+1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7
|
||||
AlF9ItgKbppbd9/w+kHsOdx1ymgHDB/qo4H1MIHyMA4GA1UdDwEB/wQEAwIBBjAd
|
||||
BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDwYDVR0TAQH/BAUwAwEB/zAd
|
||||
BgNVHQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwHwYDVR0jBBgwFoAUebRZ5nu2
|
||||
5eQBc4AIiMgaWPbpm24wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzAChhZodHRw
|
||||
Oi8veDEuaS5sZW5jci5vcmcvMBMGA1UdIAQMMAowCAYGZ4EMAQIBMCcGA1UdHwQg
|
||||
MB4wHKAaoBiGFmh0dHA6Ly94MS5jLmxlbmNyLm9yZy8wDQYJKoZIhvcNAQELBQAD
|
||||
ggIBAD2/e9frmMxNpCV03qUHegg+MV2wz9644YoXdqtH8RyWYcBO7xfjjGEXdU1e
|
||||
/o0OkEFiynUCOSIk/vLLo7ttz6CPAeNlWfC0XNkoGeWgK6jjXvozBaGuGH5n0Ufo
|
||||
shMeWTuURqNN5G00sSXDTBrpp2+mgvdZQjb8K11TYMA25QA+YHNfbIEL0BniAhKS
|
||||
2gsnJjSzrdZLI+EZ7SEyqdR2rkjd1KutLDU+n3TFyxjniZVGur4YlhMP3mY/dV95
|
||||
IruAkkjOZier6hGBdEgZXXvaCz9u9iVEadsIE75pAGL8oHV5vxdARDiotRpul1IN
|
||||
/UZwzAbrfUFcw1HkAcYD/mlZfnQ2ieCF2MS7j3Vhv7JPDKp45fmykmzYNSrumRW0
|
||||
upFFKDBOoF7hsOb7oLyHS+Uft6jOUfOrogj8YUx38hKb2K20r42OgsSdDdxdeYWc
|
||||
MS3Sb6mwJeSZEYxJ2gaXnDSPaKhhrNkYwljyVQyr4Nq+MEJytXNTnHqaAcrNwZlV
|
||||
pcJL1KBnMrMjP7eanvUwL3FYj3cF17jtboLt7gLoi4+2rWZFvn+w54jmd/FIuhhZ
|
||||
cEaU/wvU6BUNMtcVquVGHp7itQeDth5j+XL3j4WJ2SABwzUl6OeYdgpIt/ITZa+p
|
||||
TT0mQ/r5XyA4MEAiabn7XJjvCERlF2dcn2wqJw+CreTkkQ2R
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,5 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQggnJOfQM8flEJFULr
|
||||
8vvHwWRlXlJ1a0sI5Jw/Y6KRQeGhRANCAATB70bxIRjXyxdwR/3k56AkiFRKwApx
|
||||
q/h7xNXK5/I5xZ+5+HCLMHjEmFOIUtUj87DpcPHsrAfJZcH19gQIt7Xl
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -37,7 +37,6 @@ import (
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/webhook"
|
||||
"github.com/go-chi/chi/v5"
|
||||
chimw "github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
)
|
||||
|
||||
@@ -71,7 +70,7 @@ func main() {
|
||||
sessionStore := auth.NewSessionStore(database.DB, cfg)
|
||||
|
||||
// WebSocket origin allowlist
|
||||
wsOrigins := []string{"https://" + cfg.Host, "http://tauri.localhost", "https://tauri.localhost", "tauri://localhost"}
|
||||
wsOrigins := []string{"https://" + cfg.Host}
|
||||
if cfg.Host == "localhost" {
|
||||
wsOrigins = append(wsOrigins, "http://localhost:"+cfg.Port)
|
||||
}
|
||||
@@ -81,13 +80,6 @@ func main() {
|
||||
hub := gateway.NewHub(database.DB, logger)
|
||||
go hub.Run()
|
||||
|
||||
// Built-in bot runner
|
||||
botRunner := bot.NewRunner(database.DB, hub, logger)
|
||||
botRunner.Register("steamfree", bot.SteamFreeBot)
|
||||
botRunner.Register("confess", bot.ConfessBot)
|
||||
botRunner.Register("leaderboard", bot.LeaderboardBot)
|
||||
go botRunner.StartAll()
|
||||
|
||||
// Giphy client (nil if no API key)
|
||||
giphyClient := giphy.NewClient(cfg.Giphy.APIKey)
|
||||
|
||||
@@ -120,16 +112,6 @@ func main() {
|
||||
memberHandler := server.NewMemberHandler(database.DB)
|
||||
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Use(cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"https://" + cfg.Host, "http://localhost:" + cfg.Port, "http://tauri.localhost", "https://tauri.localhost", "tauri://localhost"},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
||||
ExposedHeaders: []string{"Link", "X-Session-Token"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 300,
|
||||
}))
|
||||
|
||||
r.Use(chimw.Logger)
|
||||
r.Use(chimw.Recoverer)
|
||||
r.Use(chimw.RequestID)
|
||||
@@ -146,11 +128,6 @@ func main() {
|
||||
gateway.ServeWS(database.DB, hub, logger, w, r, cfg.Session.CookieName)
|
||||
})
|
||||
|
||||
// Bot WebSocket endpoint (auth via ?token= query param)
|
||||
r.Get("/ws/bot", func(w http.ResponseWriter, r *http.Request) {
|
||||
gateway.ServeBotWS(database.DB, hub, logger, w, r)
|
||||
})
|
||||
|
||||
// API routes
|
||||
r.Route("/api/v1", func(r chi.Router) {
|
||||
// Auth (public: register, login, logout) with strict rate limiting
|
||||
@@ -163,10 +140,7 @@ func main() {
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(middleware.Session(sessionStore, cfg))
|
||||
r.Use(middleware.RequireAuth)
|
||||
r.Use(middleware.CSRFProtect(cfg.Host, cfg.Port, append(
|
||||
strings.Split(os.Getenv("DUMPSTER_CSRF_ORIGINS"), ","),
|
||||
"tauri://localhost", "http://tauri.localhost", "https://tauri.localhost",
|
||||
)))
|
||||
r.Use(middleware.CSRFProtect(cfg.Host, cfg.Port, strings.Split(os.Getenv("DUMPSTER_CSRF_ORIGINS"), ",")))
|
||||
|
||||
// Auth (protected: me, update profile)
|
||||
authHandler.RegisterProtectedRoutes(r)
|
||||
@@ -249,9 +223,7 @@ func main() {
|
||||
|
||||
// Messages (under channels)
|
||||
r.Route("/channels/{channelID}/messages", func(r chi.Router) {
|
||||
msgHandler := message.NewHandler(database.DB, hub, pushHandler, logger, permissionsChecker)
|
||||
msgHandler.SetConfessHandler(botRunner)
|
||||
msgHandler.RegisterRoutes(r)
|
||||
message.NewHandler(database.DB, hub, pushHandler, logger, permissionsChecker).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Polls
|
||||
@@ -271,26 +243,6 @@ func main() {
|
||||
notification.NewHandler(database.DB, logger).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Calendar events
|
||||
calHandler := channel.NewHandler(database.DB, permissionsChecker)
|
||||
r.Route("/channels/{channelID}/events", func(r chi.Router) {
|
||||
r.Get("/", calHandler.ListEvents)
|
||||
r.Post("/", calHandler.CreateEvent)
|
||||
})
|
||||
|
||||
// Threads (forum posts)
|
||||
threadHandler := channel.NewHandler(database.DB, permissionsChecker)
|
||||
r.Route("/channels/{channelID}/threads", func(r chi.Router) {
|
||||
r.Get("/", threadHandler.ListThreads)
|
||||
r.Post("/", threadHandler.CreateThread)
|
||||
})
|
||||
r.Patch("/threads/{threadID}", threadHandler.UpdateThread)
|
||||
|
||||
// Forum tags
|
||||
r.Get("/channels/{channelID}/forum-tags", threadHandler.ListForumTags)
|
||||
r.Post("/channels/{channelID}/forum-tags", threadHandler.CreateForumTag)
|
||||
r.Delete("/forum-tags/{tagID}", threadHandler.DeleteForumTag)
|
||||
|
||||
// Push notifications
|
||||
pushHandler.RegisterRoutes(r)
|
||||
|
||||
@@ -371,9 +323,13 @@ func main() {
|
||||
reaction.NewHandler(database.DB, hub).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Bots + slash commands
|
||||
// Bots
|
||||
r.Route("/bots", func(r chi.Router) {
|
||||
bot.NewHandler(database.DB, botRunner).RegisterRoutes(r)
|
||||
bot.NewHandler(database.DB).RegisterRoutes(r)
|
||||
})
|
||||
|
||||
// Bot slash commands
|
||||
r.Route("/bots/{botID}/commands", func(r chi.Router) {
|
||||
bot.NewCommandHandler(database.DB).RegisterCommandRoutes(r)
|
||||
})
|
||||
|
||||
@@ -431,13 +387,6 @@ func main() {
|
||||
))
|
||||
})
|
||||
|
||||
// Privacy policy page (served before SPA catch-all)
|
||||
r.HandleFunc("/privacy", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "public, max-age=3600")
|
||||
w.Write([]byte(privacyPage))
|
||||
})
|
||||
|
||||
// Static file serving for production (SPA)
|
||||
staticDir := "web/dist"
|
||||
if _, err := os.Stat(staticDir); err == nil {
|
||||
@@ -460,104 +409,3 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const privacyPage = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Privacy Policy — dumpsterChat</title>
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
background: #1d2021; color: #ebdbb2; line-height: 1.7; padding: 2rem 1rem;
|
||||
}
|
||||
main { max-width: 720px; margin: 0 auto; }
|
||||
h1 { font-size: 1.8rem; margin-bottom: 0.25rem; color: #fabd2f; }
|
||||
.subtitle { color: #a89984; font-size: 0.85rem; margin-bottom: 2rem; }
|
||||
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; color: #83a598; }
|
||||
p, li { margin-bottom: 0.6rem; }
|
||||
ul { padding-left: 1.25rem; }
|
||||
li { margin-bottom: 0.3rem; }
|
||||
a { color: #8ec07c; }
|
||||
.footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid #3c3836; font-size: 0.8rem; color: #928374; }
|
||||
.update { color: #928374; font-size: 0.8rem; margin-top: 1.5rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Privacy Policy</h1>
|
||||
<p class="subtitle"><strong>dumpsterChat</strong> — Last updated: July 17, 2026</p>
|
||||
|
||||
<h2>Overview</h2>
|
||||
<p>dumpsterChat is a self-hosted messaging platform. This privacy policy describes how your data is handled when you use the app. Because dumpsterChat is <strong>self-hosted</strong>, your data is stored on the server instance you connect to, which is operated by the server owner — not by us.</p>
|
||||
|
||||
<h2>Data We Collect</h2>
|
||||
<p>When you use dumpsterChat, the following data is stored on the server:</p>
|
||||
<ul>
|
||||
<li><strong>Account information:</strong> username, email address, avatar, and password hash (Argon2id, not reversible).</li>
|
||||
<li><strong>Messages and content:</strong> text messages, reactions, uploaded files, voice activity metadata, and poll votes.</li>
|
||||
<li><strong>Session data:</strong> login sessions stored in encrypted cookies.</li>
|
||||
</ul>
|
||||
|
||||
<h2>How We Use Your Data</h2>
|
||||
<p>Your data is used solely to operate the chat platform:</p>
|
||||
<ul>
|
||||
<li>Deliver messages and notifications to the intended recipients.</li>
|
||||
<li>Sync read states and presence (online/offline) across your devices.</li>
|
||||
<li>Provide moderation tools (kicks, bans, mutes) per server rules.</li>
|
||||
</ul>
|
||||
|
||||
<h2>No Third-Party Analytics</h2>
|
||||
<p>dumpsterChat does <strong>not</strong> include any analytics SDKs, tracking pixels, or telemetry. No usage data is sent to us or to any third party for advertising, profiling, or analytics purposes.</p>
|
||||
|
||||
<h2>Third-Party Integrations</h2>
|
||||
<p>If enabled by the server owner, optional integrations may be used:</p>
|
||||
<ul>
|
||||
<li><strong>Giphy:</strong> GIF search queries are proxied through the server to Giphy's API. No user data is shared with Giphy.</li>
|
||||
<li><strong>LiveKit:</strong> Voice and video calls use a self-hosted LiveKit server. Media streams are processed in real time and are not recorded or stored by default.</li>
|
||||
</ul>
|
||||
<p>These integrations are optional and controlled entirely by the server owner.</p>
|
||||
|
||||
<h2>Data Retention</h2>
|
||||
<p>Data is retained for as long as the server owner maintains the database. You can delete your messages or account at any time through the app. Server owners may also set message retention limits. Uploaded files persist until explicitly removed.</p>
|
||||
|
||||
<h2>Your Rights</h2>
|
||||
<p>Depending on your jurisdiction, you may have the right to:</p>
|
||||
<ul>
|
||||
<li>Request a copy of your stored data.</li>
|
||||
<li>Delete your account and associated data.</li>
|
||||
<li>Correct inaccurate personal information.</li>
|
||||
</ul>
|
||||
<p>To exercise these rights, contact the operator of the dumpsterChat instance you use, or use the account management tools available within the app.</p>
|
||||
|
||||
<h2>Account Deletion Requests</h2>
|
||||
<p>To request deletion of your account and all associated data:</p>
|
||||
<ul>
|
||||
<li>Use the <strong>Delete Account</strong> option in your account settings within the app.</li>
|
||||
<li>Or email <a href="mailto:account-deletion@dustin.coffee">account-deletion@dustin.coffee</a> from the email address associated with your account.</li>
|
||||
</ul>
|
||||
<p>We will process your request within 30 days. Deletion removes your account, messages, uploaded files, and all personal data from the server.</p>
|
||||
|
||||
<h2>Security</h2>
|
||||
<p>We take reasonable measures to protect your data:</p>
|
||||
<ul>
|
||||
<li>Passwords are hashed with Argon2id.</li>
|
||||
<li>Session tokens use httpOnly cookies.</li>
|
||||
<li>All communications are encrypted over HTTPS and WSS where available.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Children's Privacy</h2>
|
||||
<p>dumpsterChat is not directed at children under 13. We do not knowingly collect personal information from children.</p>
|
||||
|
||||
<h2>Changes to This Policy</h2>
|
||||
<p>We may update this privacy policy from time to time. Changes will be posted at this URL. Continued use of the app after changes constitutes acceptance of the updated policy.</p>
|
||||
|
||||
<h2>Contact</h2>
|
||||
<p>If you have questions about this privacy policy, contact the operator of the dumpsterChat instance you use, or open an issue on our project repository.</p>
|
||||
|
||||
<div class="update">This privacy policy applies to the dumpsterChat mobile app and web app. The specific data practices of each instance may vary based on the server operator's configuration.</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Netscape HTTP Cookie File
|
||||
# https://curl.se/docs/http-cookies.html
|
||||
# This file was generated by libcurl! Edit at your own risk.
|
||||
|
||||
#HttpOnly_localhost FALSE / TRUE 1785435515 dumpster_session 720a3aad74029e6c8e0c4b93f8db0b48381afc5355e1c1345143a0f5e3d5ae34
|
||||
@@ -8,31 +8,8 @@ export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
nvm use 22
|
||||
|
||||
# Snapshot the current binary before pulling
|
||||
if [ -f dumpster-server ]; then
|
||||
cp dumpster-server dumpster-server.bak
|
||||
echo "Backed up existing binary to dumpster-server.bak"
|
||||
fi
|
||||
|
||||
git pull
|
||||
make build
|
||||
|
||||
# Health check after restart — roll back on failure
|
||||
systemctl restart dumpster
|
||||
echo "Waiting for app to become healthy..."
|
||||
for i in $(seq 1 15); do
|
||||
if curl -sf http://localhost:8080/ > /dev/null 2>&1; then
|
||||
echo "Server is listening — deploy complete"
|
||||
rm -f dumpster-server.bak
|
||||
echo "Deploy complete — $(date)"
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Health check failed after 30s — rolling back..."
|
||||
systemctl stop dumpster
|
||||
cp dumpster-server.bak dumpster-server
|
||||
systemctl start dumpster
|
||||
echo "Rolled back to previous binary — $(date)"
|
||||
exit 1
|
||||
echo "Deploy complete — $(date)"
|
||||
|
||||
@@ -16,10 +16,8 @@ RUN npm run build
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
RUN adduser -D -g '' appuser
|
||||
WORKDIR /app
|
||||
COPY --from=go-builder /bin/dumpster-server /app/dumpster-server
|
||||
COPY --from=web-builder /app/dist /srv/web
|
||||
USER appuser
|
||||
EXPOSE 8080
|
||||
CMD sh -c "if [ -z \"$DUMPSTER_SECRET\" ]; then export DUMPSTER_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32); fi; /app/dumpster-server"
|
||||
CMD ["sh", "-c", "if [ -z \"$DUMPSTER_SECRET\" ]; then export DUMPSTER_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32); fi; /app/dumpster-server"]
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
version: '3.8'
|
||||
|
||||
networks:
|
||||
frontend:
|
||||
backend:
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
@@ -36,9 +32,6 @@ services:
|
||||
condition: service_healthy
|
||||
valkey:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- frontend
|
||||
- backend
|
||||
|
||||
postgres:
|
||||
image: postgres:16
|
||||
@@ -56,8 +49,6 @@ services:
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- backend
|
||||
|
||||
valkey:
|
||||
image: valkey/valkey:8
|
||||
@@ -71,8 +62,6 @@ services:
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
networks:
|
||||
- backend
|
||||
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
@@ -86,8 +75,6 @@ services:
|
||||
- "9001:9001"
|
||||
volumes:
|
||||
- minio_data:/data
|
||||
networks:
|
||||
- backend
|
||||
|
||||
livekit:
|
||||
image: livekit/livekit-server:latest
|
||||
@@ -102,8 +89,6 @@ services:
|
||||
- ./livekit.yaml:/etc/livekit.yaml:ro
|
||||
environment:
|
||||
LIVEKIT_KEYS: "${LIVEKIT_API_KEY:-devkey}: ${LIVEKIT_API_SECRET:-secret}"
|
||||
networks:
|
||||
- backend
|
||||
|
||||
coturn:
|
||||
image: coturn/coturn:latest
|
||||
@@ -114,8 +99,8 @@ services:
|
||||
- "--max-port=50200"
|
||||
- "--realm=${DUMPSTER_HOST:-localhost}"
|
||||
- "--user=${LIVEKIT_API_KEY:-devkey}:${LIVEKIT_API_SECRET:-secret}"
|
||||
- "--cert=/etc/letsencrypt/live/turn.dustin.coffee/fullchain.pem"
|
||||
- "--pkey=/etc/letsencrypt/live/turn.dustin.coffee/privkey.pem"
|
||||
- "--cert=/etc/coturn/certs/turn.crt"
|
||||
- "--pkey=/etc/coturn/certs/turn.key"
|
||||
- "--tls-listening-port=5349"
|
||||
ports:
|
||||
- "3478:3478/tcp"
|
||||
@@ -124,9 +109,7 @@ services:
|
||||
- "5349:5349/udp"
|
||||
- "50101-50200:50101-50200/udp"
|
||||
volumes:
|
||||
- /etc/letsencrypt:/etc/letsencrypt:ro
|
||||
networks:
|
||||
- backend
|
||||
- ./certs:/etc/coturn/certs:ro
|
||||
|
||||
caddy:
|
||||
image: caddy:2
|
||||
@@ -141,8 +124,6 @@ services:
|
||||
- caddy_config:/config
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- frontend
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
||||
@@ -9,9 +9,9 @@ rtc:
|
||||
- host: turn.dustin.coffee
|
||||
port: 443
|
||||
protocol: tls
|
||||
username: "${LIVEKIT_API_KEY}"
|
||||
credential: "${LIVEKIT_API_SECRET}"
|
||||
username: V8S6EWOU1Lqp
|
||||
credential: jQRJztgWbqDn9vjMUhHZg1ooxuhiBjhk
|
||||
turn:
|
||||
enabled: false
|
||||
keys:
|
||||
"${LIVEKIT_API_KEY}": "${LIVEKIT_API_SECRET}"
|
||||
V8S6EWOU1Lqp: jQRJztgWbqDn9vjMUhHZg1ooxuhiBjhk
|
||||
|
||||
@@ -1,369 +0,0 @@
|
||||
# Capacitor Android App — Implementation Plan
|
||||
|
||||
> **For Hermes:** Use subagent-driven-development skill to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Wrap the existing dumpsterChat Vite/React PWA in a Capacitor shell and publish to Google Play.
|
||||
|
||||
**Architecture:** Capacitor loads the Vite build output as local assets in an Android WebView. `@capacitor/core` bridges native APIs (push, status bar, etc.). No UI rewrite — the web app IS the app.
|
||||
|
||||
**Tech Stack:** Vite, React 18, Capacitor 6, FCM (push), Gradle (Android build)
|
||||
|
||||
---
|
||||
|
||||
### Phase 1: Capacitor Init
|
||||
|
||||
#### Task 1: Add Capacitor dependencies
|
||||
|
||||
**Objective:** Install Capacitor core + CLI in the web project.
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/package.json`
|
||||
|
||||
**Steps:**
|
||||
|
||||
```bash
|
||||
cd web
|
||||
npm install @capacitor/core @capacitor/cli @capacitor/android
|
||||
```
|
||||
|
||||
Then init Capacitor:
|
||||
|
||||
```bash
|
||||
npx cap init "Dumpster Chat" "coffee.dustin.dumpster" --web-dir dist
|
||||
```
|
||||
|
||||
This creates `capacitor.config.ts` at the web root.
|
||||
|
||||
**Verify:** `cat capacitor.config.ts` shows appId `coffee.dustin.dumpster`, webDir `dist`.
|
||||
|
||||
---
|
||||
|
||||
#### Task 2: Configure capacitor.config.ts
|
||||
|
||||
**Objective:** Set server URL for dev, configure Android-specific settings.
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/capacitor.config.ts`
|
||||
|
||||
**Content:**
|
||||
|
||||
```ts
|
||||
import type { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'coffee.dustin.dumpster',
|
||||
appName: 'Dumpster Chat',
|
||||
webDir: 'dist',
|
||||
server: {
|
||||
// ponytail: no server.url — serve local assets. API calls go to absolute URL from api.ts.
|
||||
androidScheme: 'https', // cookies work over https scheme in WebView
|
||||
},
|
||||
plugins: {
|
||||
PushNotifications: {
|
||||
presentationOptions: ['badge', 'sound', 'alert'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
||||
**Key decisions:**
|
||||
- `androidScheme: 'https'` makes `credentials: 'include'` cookies work in the WebView (http scheme blocks them).
|
||||
- No `server.url` — local assets load from the APK, not from the web. Faster, works offline.
|
||||
|
||||
---
|
||||
|
||||
#### Task 3: Add Android platform
|
||||
|
||||
**Objective:** Generate the native Android project.
|
||||
|
||||
**Files:**
|
||||
- Create: `web/android/` (generated by Capacitor)
|
||||
|
||||
**Steps:**
|
||||
|
||||
```bash
|
||||
cd web
|
||||
npx cap add android
|
||||
```
|
||||
|
||||
**Verify:** `ls web/android/app/src/main/AndroidManifest.xml` exists.
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: API Client Fix
|
||||
|
||||
#### Task 4: Update API base URL for native
|
||||
|
||||
**Objective:** When running in Capacitor, API calls need an absolute URL (no origin in a WebView). Keep relative paths for web/PWA.
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/src/lib/api.ts`
|
||||
|
||||
**Changes:**
|
||||
|
||||
```ts
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
// ponytail: single switch. native = absolute URL, web = relative (Caddy same-origin).
|
||||
const API_BASE = Capacitor.isNativePlatform()
|
||||
? 'https://dumpster.dustin.coffee/api/v1'
|
||||
: '/api/v1';
|
||||
```
|
||||
|
||||
The rest of the file stays unchanged. `Capacitor.isNativePlatform()` returns `false` in browsers and `true` in the Android WebView.
|
||||
|
||||
**Skipped:** `@capacitor/http` plugin. Not needed — `androidScheme: 'https'` + absolute URL + `credentials: 'include'` works. Add the HTTP plugin only if cookies break.
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Push Notifications (FCM)
|
||||
|
||||
This is the only non-trivial part. VAPID web push does not work in Android WebViews. Need FCM.
|
||||
|
||||
#### Task 5: Create Firebase project
|
||||
|
||||
**Objective:** Set up FCM credentials for native push.
|
||||
|
||||
**Steps (manual, one-time):**
|
||||
1. Go to https://console.firebase.google.com
|
||||
2. Create project (or use existing) named `dumpster-chat`
|
||||
3. Add Android app with package name `coffee.dustin.dumpster`
|
||||
4. Download `google-services.json` → place in `web/android/app/google-services.json`
|
||||
5. In Firebase Console → Project Settings → Cloud Messaging → note the **Server Key** (legacy) or set up **Firebase Admin SDK** service account
|
||||
|
||||
**Verify:** `google-services.json` exists in `web/android/app/`.
|
||||
|
||||
---
|
||||
|
||||
#### Task 6: Add Capacitor Push Notifications plugin
|
||||
|
||||
**Objective:** Register for FCM token on Android, send it to the server.
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/package.json` (install plugin)
|
||||
- Modify: `web/src/stores/push.ts` (add native branch)
|
||||
|
||||
**Install:**
|
||||
```bash
|
||||
cd web
|
||||
npm install @capacitor/push-notifications
|
||||
```
|
||||
|
||||
**Modify `push.ts`** — add a native registration path alongside the existing web push:
|
||||
|
||||
```ts
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
// Existing web push subscribe stays as-is for PWA.
|
||||
// Add native branch:
|
||||
async function subscribeNative() {
|
||||
const { PushNotifications } = await import('@capacitor/push-notifications');
|
||||
|
||||
const permStatus = await PushNotifications.requestPermissions();
|
||||
if (permStatus.receive !== 'granted') return;
|
||||
|
||||
await PushNotifications.register();
|
||||
|
||||
// Server sends us the FCM token via this event
|
||||
PushNotifications.addListener('registration', async (token) => {
|
||||
await api.post('/push/subscribe', {
|
||||
endpoint: 'fcm:' + token.value, // ponytail: prefix to distinguish from web push endpoints
|
||||
keys: { p256dh: '', auth: '' }, // not used for FCM, but server expects the shape
|
||||
});
|
||||
});
|
||||
|
||||
PushNotifications.addListener('pushNotificationReceived', (notification) => {
|
||||
// Foreground notification — show in-app toast or badge
|
||||
// ponytail: handled by existing in-app notification system
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
Then in the existing `subscribe()` function, branch:
|
||||
|
||||
```ts
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
return subscribeNative();
|
||||
}
|
||||
// ... existing web push logic
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Task 7: Server-side FCM send support
|
||||
|
||||
**Objective:** When a push subscription's endpoint starts with `fcm:`, send via FCM HTTP v1 API instead of VAPID.
|
||||
|
||||
**Files:**
|
||||
- Modify: `internal/push/handlers.go`
|
||||
|
||||
**Changes:**
|
||||
1. In `Subscribe()`: detect `fcm:` prefix on endpoint, store differently (or store as-is, the prefix distinguishes it).
|
||||
2. In the send functions (`Send`, `SendToUser`): check if subscription endpoint starts with `fcm:` → use Firebase Admin SDK to send.
|
||||
|
||||
**Install Go Firebase Admin:**
|
||||
```bash
|
||||
go get firebase.google.com/go/v4
|
||||
```
|
||||
|
||||
**Pattern:**
|
||||
```go
|
||||
// ponytail: one if/else in the send loop. endpoint prefix = routing key.
|
||||
if strings.HasPrefix(sub.Endpoint, "fcm:") {
|
||||
token := strings.TrimPrefix(sub.Endpoint, "fcm:")
|
||||
msg := &messaging.Message{
|
||||
Token: token,
|
||||
Notification: &messaging.Notification{
|
||||
Title: title,
|
||||
Body: body,
|
||||
},
|
||||
Data: map[string]string{"url": url},
|
||||
}
|
||||
_, err = fcmClient.Send(ctx, msg)
|
||||
} else {
|
||||
// existing VAPID webpush send
|
||||
}
|
||||
```
|
||||
|
||||
**Config:** Add `FIREBASE_CREDENTIALS_FILE` env var (path to service account JSON) to the systemd unit / Docker compose.
|
||||
|
||||
**Skipped:** Topic-based broadcast. Per-device tokens is fine for now. Add topics when channel count grows.
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Gradle / Build Config
|
||||
|
||||
#### Task 8: Configure Android build
|
||||
|
||||
**Objective:** Set minimum SDK, app icon, theme.
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/android/app/build.gradle`
|
||||
- Modify: `web/android/app/src/main/res/values/strings.xml`
|
||||
|
||||
**Changes in `build.gradle`:**
|
||||
```gradle
|
||||
minSdkVersion = 24 // ponytail: Android 7+ covers 99% of Play Store. lower = more compat bugs.
|
||||
```
|
||||
|
||||
**App name in `strings.xml`:**
|
||||
```xml
|
||||
<string name="app_name">Dumpster Chat</string>
|
||||
```
|
||||
|
||||
**App icon:** Copy existing PWA icons into Android mipmap directories:
|
||||
```bash
|
||||
# Capacitor can sync icons automatically if placed at web/public/icon.png (1024x1024)
|
||||
# or manually: web/android/app/src/main/res/mipmap-*/
|
||||
npx cap assets generate # if a 1024x1024 source icon exists
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Build & Publish
|
||||
|
||||
#### Task 9: Sync and build debug APK
|
||||
|
||||
**Objective:** Verify the app runs on a real device or emulator.
|
||||
|
||||
**Steps:**
|
||||
```bash
|
||||
cd web
|
||||
npm run build # builds Vite → dist/
|
||||
npx cap sync android # copies dist/ into android/assets, syncs plugins
|
||||
cd android
|
||||
./gradlew assembleDebug
|
||||
```
|
||||
|
||||
**Output:** `web/android/app/build/outputs/apk/debug/app-debug.apk`
|
||||
|
||||
**Verify:** Install on Android device:
|
||||
```bash
|
||||
adb install app-debug.apk
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Task 10: Build signed release AAB for Play Store
|
||||
|
||||
**Objective:** Create a signed Android App Bundle (.aab) for Google Play upload.
|
||||
|
||||
**Steps:**
|
||||
1. Generate keystore (one-time):
|
||||
```bash
|
||||
keytool -genkey -v -keystore dumpster-release.jks -keyalg RSA -keysize 2048 -validity 10000 -alias dumpster
|
||||
```
|
||||
Store `dumpster-release.jks` securely. Back it up. Lose it = can't update the app.
|
||||
|
||||
2. Add signing config to `web/android/app/build.gradle`:
|
||||
```gradle
|
||||
android {
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('dumpster-release.jks')
|
||||
storePassword System.getenv('KEYSTORE_PASSWORD')
|
||||
keyAlias 'dumpster'
|
||||
keyPassword System.getenv('KEY_PASSWORD')
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Build AAB:
|
||||
```bash
|
||||
cd web/android
|
||||
KEYSTORE_PASSWORD=xxx KEY_PASSWORD=xxx ./gradlew bundleRelease
|
||||
```
|
||||
|
||||
**Output:** `web/android/app/build/outputs/bundle/release/app-release.aab`
|
||||
|
||||
4. Upload to Google Play Console → your new developer account → Create app → Upload AAB.
|
||||
|
||||
---
|
||||
|
||||
#### Task 11: Clean up Tauri dependencies
|
||||
|
||||
**Objective:** Remove unused Tauri packages (pivoted away from Tauri).
|
||||
|
||||
**Files:**
|
||||
- Modify: `web/package.json`
|
||||
|
||||
**Steps:**
|
||||
```bash
|
||||
cd web
|
||||
npm uninstall @tauri-apps/api @tauri-apps/cli
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Summary
|
||||
|
||||
| Phase | What | Time estimate |
|
||||
|-------|------|---------------|
|
||||
| 1 | Capacitor init + Android platform | 10 min |
|
||||
| 2 | API base URL native branch | 5 min |
|
||||
| 3 | FCM push (plugin + server) | 1-2 hrs (incl. Firebase setup) |
|
||||
| 4 | Gradle config / icons | 15 min |
|
||||
| 5 | Build, test, publish | 30 min |
|
||||
|
||||
**Total:** ~2-3 hours end-to-end. Phase 3 is the only real work.
|
||||
|
||||
**Dependencies between tasks:**
|
||||
- Tasks 1-3 sequential (Capacitor init)
|
||||
- Task 4 independent of 5-7
|
||||
- Tasks 5-7 sequential (FCM chain)
|
||||
- Task 8 depends on 1-3
|
||||
- Task 9 depends on all above
|
||||
- Task 10 depends on 9
|
||||
- Task 11 independent, do anytime
|
||||
|
||||
**After this plan:** Update the Makefile `build` target to include `npm run build && npx cap sync android` so deploys sync native assets too.
|
||||
@@ -1,198 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
// ---- config from env ----
|
||||
|
||||
var (
|
||||
botToken string
|
||||
host string
|
||||
channelID string
|
||||
pollMinutes int
|
||||
seen = map[string]bool{} // appid -> posted
|
||||
)
|
||||
|
||||
// ---- dumpsterChat WS protocol ----
|
||||
|
||||
type Event struct {
|
||||
Type string `json:"type"`
|
||||
Payload json.RawMessage `json:"payload"`
|
||||
}
|
||||
|
||||
// ---- Steam API response ----
|
||||
|
||||
type FeaturedCategories struct {
|
||||
Specials FeaturedList `json:"specials"`
|
||||
}
|
||||
|
||||
type FeaturedList struct {
|
||||
Items []FeaturedItem `json:"items"`
|
||||
}
|
||||
|
||||
type FeaturedItem struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DiscountPct int `json:"discount_percent"`
|
||||
FinalPrice int `json:"final_price"` // in cents
|
||||
OriginalPrice int `json:"original_price"` // in cents
|
||||
}
|
||||
|
||||
func main() {
|
||||
botToken = os.Getenv("BOT_TOKEN")
|
||||
if botToken == "" {
|
||||
log.Fatal("BOT_TOKEN required (create a bot in the dumpsterChat store)")
|
||||
}
|
||||
host = os.Getenv("DUMPSTER_HOST")
|
||||
if host == "" {
|
||||
host = "localhost:8080"
|
||||
}
|
||||
channelID = os.Getenv("CHANNEL_ID")
|
||||
if channelID == "" {
|
||||
log.Fatal("CHANNEL_ID required (the channel to post free games to)")
|
||||
}
|
||||
pollMinutes = 30
|
||||
if m := os.Getenv("POLL_MINUTES"); m != "" {
|
||||
if v, err := strconv.Atoi(m); err == nil && v > 0 {
|
||||
pollMinutes = v
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to dumpsterChat
|
||||
u := url.URL{
|
||||
Scheme: "ws",
|
||||
Host: host,
|
||||
Path: "/ws/bot",
|
||||
RawQuery: "token=" + botToken,
|
||||
}
|
||||
|
||||
log.Printf("SteamFree bot connecting to %s", u.String())
|
||||
|
||||
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
|
||||
if err != nil {
|
||||
log.Fatal("dial:", err)
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
log.Println("SteamFree bot connected!")
|
||||
|
||||
// First poll immediately, then on ticker
|
||||
poll(c)
|
||||
|
||||
ticker := time.NewTicker(time.Duration(pollMinutes) * time.Minute)
|
||||
defer ticker.Stop()
|
||||
|
||||
// Keep connection alive by reading (we don't need to react to events)
|
||||
go func() {
|
||||
for {
|
||||
_, _, err := c.ReadMessage()
|
||||
if err != nil {
|
||||
log.Println("ws read:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
for range ticker.C {
|
||||
poll(c)
|
||||
}
|
||||
}
|
||||
|
||||
func poll(c *websocket.Conn) {
|
||||
log.Println("Polling Steam for free games...")
|
||||
|
||||
games, err := fetchFreeGames()
|
||||
if err != nil {
|
||||
log.Println("fetch error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
newCount := 0
|
||||
for _, g := range games {
|
||||
if seen[strconv.Itoa(g.ID)] {
|
||||
continue
|
||||
}
|
||||
seen[strconv.Itoa(g.ID)] = true
|
||||
newCount++
|
||||
|
||||
msg := formatGame(g)
|
||||
sendMessage(c, channelID, msg)
|
||||
log.Printf("Posted: %s (was $%.2f, now FREE)", g.Name, float64(g.OriginalPrice)/100)
|
||||
time.Sleep(500 * time.Millisecond) // be polite to the WS
|
||||
}
|
||||
|
||||
if newCount == 0 {
|
||||
log.Println("No new free games found")
|
||||
} else {
|
||||
log.Printf("Posted %d new free games", newCount)
|
||||
}
|
||||
}
|
||||
|
||||
func fetchFreeGames() ([]FeaturedItem, error) {
|
||||
client := &http.Client{Timeout: 15 * time.Second}
|
||||
resp, err := client.Get("https://store.steampowered.com/api/featuredcategories?cc=us&l=english")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("steam api: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("steam api: status %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read body: %w", err)
|
||||
}
|
||||
|
||||
var cats FeaturedCategories
|
||||
if err := json.Unmarshal(body, &cats); err != nil {
|
||||
return nil, fmt.Errorf("parse json: %w", err)
|
||||
}
|
||||
|
||||
// Filter: 100% discount and actually had a price (not permanent free-to-play)
|
||||
var free []FeaturedItem
|
||||
for _, item := range cats.Specials.Items {
|
||||
if item.DiscountPct == 100 && item.OriginalPrice > 0 {
|
||||
free = append(free, item)
|
||||
}
|
||||
}
|
||||
|
||||
return free, nil
|
||||
}
|
||||
|
||||
func formatGame(g FeaturedItem) string {
|
||||
storeURL := fmt.Sprintf("https://store.steampowered.com/app/%d", g.ID)
|
||||
|
||||
var b strings.Builder
|
||||
fmt.Fprintf(&b, "🎮 **FREE ON STEAM** 🎮\n")
|
||||
fmt.Fprintf(&b, "**%s**\n", g.Name)
|
||||
fmt.Fprintf(&b, "~~$%.2f~~ → **FREE**\n", float64(g.OriginalPrice)/100)
|
||||
fmt.Fprintf(&b, "%s", storeURL)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func sendMessage(c *websocket.Conn, channelID, content string) {
|
||||
msg := map[string]interface{}{
|
||||
"type": "SEND_MESSAGE",
|
||||
"payload": map[string]string{
|
||||
"channel_id": channelID,
|
||||
"content": content,
|
||||
},
|
||||
}
|
||||
data, _ := json.Marshal(msg)
|
||||
c.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
@@ -49,7 +49,6 @@ require (
|
||||
github.com/fsnotify/fsnotify v1.10.1 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
|
||||
github.com/gammazero/deque v1.2.1 // indirect
|
||||
github.com/go-chi/cors v1.2.2 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
|
||||
@@ -87,8 +87,6 @@ github.com/gammazero/deque v1.2.1 h1:9fnQVFCCZ9/NOc7ccTNqzoKd1tCWOqeI05/lPqFPMGQ
|
||||
github.com/gammazero/deque v1.2.1/go.mod h1:5nSFkzVm+afG9+gy0VIowlqVAW4N8zNcMne+CMQVD2g=
|
||||
github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM=
|
||||
github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
|
||||
github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE=
|
||||
github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
|
||||
@@ -21,4 +21,3 @@ func SetSessionCookie(w http.ResponseWriter, cookieName, token string, duration
|
||||
MaxAge: int(duration.Seconds()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,10 @@ func (h *Handler) RequestVerification(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
token := generateToken()
|
||||
tokenHash := hashToken(token)
|
||||
_, err = h.db.ExecContext(r.Context(), `
|
||||
INSERT INTO user_tokens (user_id, token, type, expires_at)
|
||||
VALUES ($1, $2, 'verify_email', NOW() + INTERVAL '24 hours')
|
||||
`, userID, tokenHash)
|
||||
`, userID, token)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate token"}`, http.StatusInternalServerError)
|
||||
return
|
||||
@@ -64,7 +63,7 @@ func (h *Handler) VerifyEmail(w http.ResponseWriter, r *http.Request) {
|
||||
DELETE FROM user_tokens
|
||||
WHERE token = $1 AND type = 'verify_email' AND expires_at > NOW()
|
||||
RETURNING user_id
|
||||
`, hashToken(req.Token)).Scan(&userID)
|
||||
`, req.Token).Scan(&userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"invalid or expired token"}`, http.StatusBadRequest)
|
||||
return
|
||||
@@ -101,11 +100,10 @@ func (h *Handler) RequestPasswordReset(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
token := generateToken()
|
||||
tokenHash := hashToken(token)
|
||||
_, err = h.db.ExecContext(r.Context(), `
|
||||
INSERT INTO user_tokens (user_id, token, type, expires_at)
|
||||
VALUES ($1, $2, 'reset_password', NOW() + INTERVAL '1 hour')
|
||||
`, userID, tokenHash)
|
||||
`, userID, token)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate token"}`, http.StatusInternalServerError)
|
||||
return
|
||||
@@ -136,7 +134,7 @@ func (h *Handler) ResetPassword(w http.ResponseWriter, r *http.Request) {
|
||||
DELETE FROM user_tokens
|
||||
WHERE token = $1 AND type = 'reset_password' AND expires_at > NOW()
|
||||
RETURNING user_id
|
||||
`, hashToken(req.Token)).Scan(&userID)
|
||||
`, req.Token).Scan(&userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"invalid or expired token"}`, http.StatusBadRequest)
|
||||
return
|
||||
|
||||
@@ -50,7 +50,6 @@ func (h *Handler) RegisterProtectedRoutes(r chi.Router) {
|
||||
r.Get("/auth/me", h.Me)
|
||||
r.Patch("/auth/me", h.UpdateProfile)
|
||||
r.Put("/auth/me/password", h.ChangePassword)
|
||||
r.Delete("/auth/me", h.DeleteAccount)
|
||||
r.Get("/users/{userID}/profile", h.GetPublicProfile)
|
||||
r.Get("/users/me/blocks", h.ListBlocks)
|
||||
r.Post("/users/me/blocks", h.BlockUser)
|
||||
@@ -332,7 +331,6 @@ func (h *Handler) Register(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
h.setSessionCookie(w, token)
|
||||
w.Header().Set("X-Session-Token", token)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"id": userID})
|
||||
}
|
||||
@@ -385,7 +383,6 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
h.setSessionCookie(w, token)
|
||||
w.Header().Set("X-Session-Token", token)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"id": userID})
|
||||
}
|
||||
@@ -663,32 +660,3 @@ func (h *Handler) ChangePassword(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"message": "password updated"})
|
||||
}
|
||||
|
||||
// DeleteAccount deletes the authenticated user and all associated data.
|
||||
// ponytail: cascading FK handles all DB cleanup — push subscriptions cleaned manually.
|
||||
func (h *Handler) DeleteAccount(w http.ResponseWriter, r *http.Request) {
|
||||
userID, ok := middleware.UserIDFromContext(r.Context())
|
||||
if !ok {
|
||||
http.Error(w, `{"error":"unauthorized"}`, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
// Clean up push subscriptions
|
||||
h.db.ExecContext(r.Context(), `DELETE FROM push_subscriptions WHERE user_id = $1`, userID)
|
||||
|
||||
// ON DELETE CASCADE handles everything else: sessions, tokens, messages,
|
||||
// reactions, memberships, invites, bots, etc.
|
||||
result, err := h.db.ExecContext(r.Context(), `DELETE FROM users WHERE id = $1`, userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to delete account"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
rows, _ := result.RowsAffected()
|
||||
if rows == 0 {
|
||||
http.Error(w, `{"error":"user not found"}`, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"message": "account deleted"})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package auth
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@@ -21,25 +20,17 @@ func NewSessionStore(db *sql.DB, cfg *config.Config) *SessionStore {
|
||||
return &SessionStore{db: db, cfg: cfg}
|
||||
}
|
||||
|
||||
// hashToken computes a SHA-256 hash of a token string.
|
||||
// Tokens are stored hashed in the DB so a DB leak doesn't expose active sessions.
|
||||
func hashToken(token string) string {
|
||||
h := sha256.Sum256([]byte(token))
|
||||
return hex.EncodeToString(h[:])
|
||||
}
|
||||
|
||||
func (s *SessionStore) Create(ctx context.Context, userID string) (string, error) {
|
||||
b := make([]byte, 32)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
return "", fmt.Errorf("generate token: %w", err)
|
||||
}
|
||||
token := hex.EncodeToString(b)
|
||||
tokenHash := hashToken(token)
|
||||
|
||||
_, err := s.db.ExecContext(ctx, `
|
||||
INSERT INTO sessions (user_id, token, expires_at)
|
||||
VALUES ($1, $2, $3)
|
||||
`, userID, tokenHash, time.Now().Add(s.cfg.Session.Duration))
|
||||
`, userID, token, time.Now().Add(s.cfg.Session.Duration))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("insert session: %w", err)
|
||||
}
|
||||
@@ -52,7 +43,7 @@ func (s *SessionStore) GetUserIDByToken(ctx context.Context, token string) (stri
|
||||
err := s.db.QueryRowContext(ctx, `
|
||||
SELECT user_id FROM sessions
|
||||
WHERE token = $1 AND expires_at > NOW()
|
||||
`, hashToken(token)).Scan(&userID)
|
||||
`, token).Scan(&userID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -60,6 +51,6 @@ func (s *SessionStore) GetUserIDByToken(ctx context.Context, token string) (stri
|
||||
}
|
||||
|
||||
func (s *SessionStore) Delete(ctx context.Context, token string) error {
|
||||
_, err := s.db.ExecContext(ctx, `DELETE FROM sessions WHERE token = $1`, hashToken(token))
|
||||
_, err := s.db.ExecContext(ctx, `DELETE FROM sessions WHERE token = $1`, token)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -234,8 +234,7 @@ func (h *WebAuthnHandler) LoginBegin(w http.ResponseWriter, r *http.Request) {
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
MaxAge: 300, // 5 minutes
|
||||
SameSite: http.SameSiteNoneMode,
|
||||
Secure: true,
|
||||
SameSite: http.SameSiteStrictMode,
|
||||
})
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -342,11 +341,9 @@ func (h *WebAuthnHandler) LoginFinish(w http.ResponseWriter, r *http.Request) {
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
MaxAge: -1,
|
||||
SameSite: http.SameSiteNoneMode,
|
||||
Secure: true,
|
||||
SameSite: http.SameSiteStrictMode,
|
||||
})
|
||||
|
||||
w.Header().Set("X-Session-Token", token)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{"status": "authenticated"})
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ConfessConfig: "channel_id" is where anonymous confessions land.
|
||||
type ConfessConfig struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
}
|
||||
|
||||
// parseConfessContent returns the confession body if content is a /confess command.
|
||||
func parseConfessContent(content string) (string, bool) {
|
||||
trimmed := strings.TrimSpace(content)
|
||||
if len(trimmed) < 8 || !strings.EqualFold(trimmed[:8], "/confess") {
|
||||
return "", false
|
||||
}
|
||||
// Require word boundary after the command (space, end, or more text after optional space).
|
||||
rest := strings.TrimSpace(trimmed[8:])
|
||||
if rest == "" {
|
||||
return "", false
|
||||
}
|
||||
return rest, true
|
||||
}
|
||||
|
||||
// ConfessBot is a safety-net poller for any /confess that slipped past intercept.
|
||||
// Primary path is Runner.TryConfess at message create (no original ever stored).
|
||||
func ConfessBot(ctx context.Context, db *sql.DB, raw json.RawMessage, send SendMessageFunc) {
|
||||
// Polling path is intentionally inert for normal operation when intercept works.
|
||||
// Keep a lightweight no-op loop so the runner lifecycle stays consistent.
|
||||
// Real cleanup of any leaked /confess rows is handled if deleteMsg is wired later.
|
||||
_ = db
|
||||
_ = raw
|
||||
_ = send
|
||||
|
||||
ticker := time.NewTicker(30 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
// no-op: intercept handles live confessions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// confessFormat is shared with TryConfess.
|
||||
func confessFormat(text string) string {
|
||||
return fmt.Sprintf("🕵️ **anonymous confession:** %s", text)
|
||||
}
|
||||
@@ -12,19 +12,16 @@ import (
|
||||
|
||||
// Handler handles bot CRUD and server-assignment routes.
|
||||
type Handler struct {
|
||||
db *sql.DB
|
||||
runner *Runner
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
// NewHandler creates a new bot Handler.
|
||||
func NewHandler(db *sql.DB, runner *Runner) *Handler {
|
||||
return &Handler{db: db, runner: runner}
|
||||
func NewHandler(db *sql.DB) *Handler {
|
||||
return &Handler{db: db}
|
||||
}
|
||||
|
||||
// RegisterRoutes registers authenticated bot routes under the given router.
|
||||
func (h *Handler) RegisterRoutes(r chi.Router) {
|
||||
r.Get("/store", h.Store)
|
||||
r.Get("/types", h.ListTypes)
|
||||
r.Post("/", h.Create)
|
||||
r.Get("/", h.List)
|
||||
r.Get("/{botID}", h.Get)
|
||||
@@ -38,14 +35,12 @@ func (h *Handler) RegisterRoutes(r chi.Router) {
|
||||
// ---- response / request types ----
|
||||
|
||||
type botResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Avatar *string `json:"avatar"`
|
||||
Description string `json:"description"`
|
||||
BotType string `json:"bot_type"`
|
||||
Config json.RawMessage `json:"config"`
|
||||
OwnerID string `json:"owner_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Avatar *string `json:"avatar"`
|
||||
Description string `json:"description"`
|
||||
OwnerID string `json:"owner_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// botWithToken is returned only on create / regenerate-token.
|
||||
@@ -55,18 +50,14 @@ type botWithToken struct {
|
||||
}
|
||||
|
||||
type createBotRequest struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
BotType string `json:"bot_type"`
|
||||
Config json.RawMessage `json:"config"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type updateBotRequest struct {
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
Avatar *string `json:"avatar"`
|
||||
BotType *string `json:"bot_type"`
|
||||
Config json.RawMessage `json:"config"`
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
Avatar *string `json:"avatar"`
|
||||
}
|
||||
|
||||
type addToServerRequest struct {
|
||||
@@ -118,21 +109,15 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
token := GenerateToken()
|
||||
tokenHash := HashToken(token)
|
||||
|
||||
configJSON := req.Config
|
||||
if configJSON == nil {
|
||||
configJSON = json.RawMessage(`{}`)
|
||||
}
|
||||
|
||||
var bot botWithToken
|
||||
var avatar sql.NullString
|
||||
var createdAt sql.NullString
|
||||
var configOut sql.NullString
|
||||
err := h.db.QueryRowContext(r.Context(), `
|
||||
INSERT INTO bots (name, description, owner_id, token, bot_type, config)
|
||||
VALUES ($1, $2, $3, $4, $5, $6::jsonb)
|
||||
RETURNING id, name, avatar, description, bot_type, config::text, owner_id, created_at::text
|
||||
`, req.Name, req.Description, userID, tokenHash, req.BotType, string(configJSON)).Scan(
|
||||
&bot.ID, &bot.Name, &avatar, &bot.Description, &bot.BotType, &configOut, &bot.OwnerID, &createdAt,
|
||||
INSERT INTO bots (name, description, owner_id, token)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, name, avatar, description, owner_id, created_at::text
|
||||
`, req.Name, req.Description, userID, tokenHash).Scan(
|
||||
&bot.ID, &bot.Name, &avatar, &bot.Description, &bot.OwnerID, &createdAt,
|
||||
)
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "failed to create bot")
|
||||
@@ -141,17 +126,9 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
if avatar.Valid {
|
||||
bot.Avatar = &avatar.String
|
||||
}
|
||||
if configOut.Valid {
|
||||
bot.Config = json.RawMessage(configOut.String)
|
||||
}
|
||||
bot.CreatedAt = createdAt.String
|
||||
bot.Token = token
|
||||
|
||||
// Start built-in bot if type is set
|
||||
if req.BotType != "" && h.runner != nil {
|
||||
h.runner.Start(bot.ID, req.BotType, bot.Config)
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusCreated, bot)
|
||||
}
|
||||
|
||||
@@ -304,18 +281,15 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
||||
var b botResponse
|
||||
var avatar sql.NullString
|
||||
var createdAt sql.NullString
|
||||
var configOut sql.NullString
|
||||
err = h.db.QueryRowContext(r.Context(), `
|
||||
UPDATE bots
|
||||
SET name = COALESCE($1, name),
|
||||
description = COALESCE($2, description),
|
||||
avatar = COALESCE($3, avatar),
|
||||
bot_type = COALESCE($5, bot_type),
|
||||
config = COALESCE($6::jsonb, config)
|
||||
avatar = COALESCE($3, avatar)
|
||||
WHERE id = $4
|
||||
RETURNING id, name, avatar, description, bot_type, config::text, owner_id, created_at::text
|
||||
`, req.Name, req.Description, req.Avatar, botID, req.BotType, string(req.Config)).Scan(
|
||||
&b.ID, &b.Name, &avatar, &b.Description, &b.BotType, &configOut, &b.OwnerID, &createdAt,
|
||||
RETURNING id, name, avatar, description, owner_id, created_at::text
|
||||
`, req.Name, req.Description, req.Avatar, botID).Scan(
|
||||
&b.ID, &b.Name, &avatar, &b.Description, &b.OwnerID, &createdAt,
|
||||
)
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "failed to update bot")
|
||||
@@ -324,22 +298,8 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
||||
if avatar.Valid {
|
||||
b.Avatar = &avatar.String
|
||||
}
|
||||
if configOut.Valid {
|
||||
b.Config = json.RawMessage(configOut.String)
|
||||
}
|
||||
b.CreatedAt = createdAt.String
|
||||
|
||||
// Restart built-in bot if type/config changed
|
||||
if req.BotType != nil && h.runner != nil {
|
||||
h.runner.Stop(b.ID)
|
||||
if *req.BotType != "" {
|
||||
h.runner.Start(b.ID, *req.BotType, b.Config)
|
||||
}
|
||||
} else if req.Config != nil && h.runner != nil && b.BotType != "" {
|
||||
h.runner.Stop(b.ID)
|
||||
h.runner.Start(b.ID, b.BotType, b.Config)
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, b)
|
||||
}
|
||||
|
||||
@@ -385,11 +345,6 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Stop built-in bot if running
|
||||
if h.runner != nil {
|
||||
h.runner.Stop(botID)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
@@ -592,64 +547,3 @@ func (h *Handler) RegenerateToken(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
writeJSON(w, http.StatusOK, b)
|
||||
}
|
||||
|
||||
// ---- Store (public listing) ----
|
||||
|
||||
type storeBotResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Avatar *string `json:"avatar"`
|
||||
Description string `json:"description"`
|
||||
ServerCount int `json:"server_count"`
|
||||
OwnerID string `json:"owner_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
// Store returns all bots with their server count (visible to any authenticated user).
|
||||
func (h *Handler) Store(w http.ResponseWriter, r *http.Request) {
|
||||
rows, err := h.db.QueryContext(r.Context(), `
|
||||
SELECT b.id, b.name, b.avatar, b.description, b.owner_id, b.created_at::text,
|
||||
COUNT(bs.server_id) AS server_count
|
||||
FROM bots b
|
||||
LEFT JOIN bot_servers bs ON bs.bot_id = b.id
|
||||
GROUP BY b.id, b.name, b.avatar, b.description, b.owner_id, b.created_at
|
||||
ORDER BY server_count DESC, b.name
|
||||
`)
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "server error")
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
bots := make([]storeBotResponse, 0)
|
||||
for rows.Next() {
|
||||
var b storeBotResponse
|
||||
var avatar sql.NullString
|
||||
var createdAt sql.NullString
|
||||
if err := rows.Scan(&b.ID, &b.Name, &avatar, &b.Description, &b.OwnerID, &createdAt, &b.ServerCount); err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "server error")
|
||||
return
|
||||
}
|
||||
if avatar.Valid {
|
||||
b.Avatar = &avatar.String
|
||||
}
|
||||
b.CreatedAt = createdAt.String
|
||||
bots = append(bots, b)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, "server error")
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, bots)
|
||||
}
|
||||
|
||||
// ListTypes returns available built-in bot types.
|
||||
func (h *Handler) ListTypes(w http.ResponseWriter, r *http.Request) {
|
||||
if h.runner == nil {
|
||||
writeJSON(w, http.StatusOK, []string{})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, h.runner.RegisteredTypes())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LeaderboardConfig: "channel_id" is where the daily recap lands.
|
||||
type LeaderboardConfig struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
}
|
||||
|
||||
// LeaderboardBot posts a daily shitpost recap.
|
||||
func LeaderboardBot(ctx context.Context, db *sql.DB, raw json.RawMessage, send SendMessageFunc) {
|
||||
var cfg LeaderboardConfig
|
||||
if err := json.Unmarshal(raw, &cfg); err != nil || cfg.ChannelID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(24 * time.Hour)
|
||||
defer ticker.Stop()
|
||||
|
||||
// Post immediately on start, then daily
|
||||
postLeaderboard(db, cfg.ChannelID, send)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
postLeaderboard(db, cfg.ChannelID, send)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func postLeaderboard(db *sql.DB, channelID string, send SendMessageFunc) {
|
||||
// ponytail: global lock on count. per-user aggregates if throughput matters.
|
||||
since := time.Now().Add(-24 * time.Hour)
|
||||
|
||||
rows, err := db.QueryContext(context.Background(), `
|
||||
SELECT u.username, COUNT(*) AS msg_count
|
||||
FROM messages m
|
||||
JOIN users u ON m.author_id = u.id
|
||||
WHERE m.created_at > $1 AND m.bot_id IS NULL
|
||||
GROUP BY u.username
|
||||
ORDER BY msg_count DESC
|
||||
LIMIT 10
|
||||
`, since)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("🏆 **24H SHITPOST LEADERBOARD** 🏆\n")
|
||||
|
||||
rank := 1
|
||||
for rows.Next() {
|
||||
var username string
|
||||
var count int
|
||||
if err := rows.Scan(&username, &count); err != nil {
|
||||
continue
|
||||
}
|
||||
medal := ""
|
||||
switch rank {
|
||||
case 1:
|
||||
medal = "🥇"
|
||||
case 2:
|
||||
medal = "🥈"
|
||||
case 3:
|
||||
medal = "🥉"
|
||||
}
|
||||
fmt.Fprintf(&b, "%s #%d **%s** — %d msgs\n", medal, rank, username, count)
|
||||
rank++
|
||||
}
|
||||
if rank == 1 {
|
||||
b.WriteString("*crickets*\n")
|
||||
}
|
||||
|
||||
send(channelID, strings.TrimSpace(b.String()))
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"sync"
|
||||
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/gateway"
|
||||
)
|
||||
|
||||
// BotFunc is the signature for a built-in bot type's run function.
|
||||
// It blocks until ctx is cancelled. Use send to post messages, db to read.
|
||||
type BotFunc func(ctx context.Context, db *sql.DB, config json.RawMessage, send SendMessageFunc)
|
||||
|
||||
// SendMessageFunc posts a message to a channel as this bot.
|
||||
type SendMessageFunc func(channelID, content string)
|
||||
|
||||
// Runner manages server-side bot goroutines.
|
||||
type Runner struct {
|
||||
db *sql.DB
|
||||
hub *gateway.Hub
|
||||
logger *slog.Logger
|
||||
|
||||
mu sync.Mutex
|
||||
bots map[string]context.CancelFunc // botID -> cancel
|
||||
types map[string]BotFunc // type name -> runner
|
||||
}
|
||||
|
||||
func NewRunner(db *sql.DB, hub *gateway.Hub, logger *slog.Logger) *Runner {
|
||||
return &Runner{
|
||||
db: db,
|
||||
hub: hub,
|
||||
logger: logger,
|
||||
bots: make(map[string]context.CancelFunc),
|
||||
types: make(map[string]BotFunc),
|
||||
}
|
||||
}
|
||||
|
||||
// Register adds a built-in bot type.
|
||||
func (r *Runner) Register(name string, fn BotFunc) {
|
||||
r.types[name] = fn
|
||||
}
|
||||
|
||||
// StartAll loads all bots with a bot_type set and starts them.
|
||||
func (r *Runner) StartAll() {
|
||||
rows, err := r.db.QueryContext(context.Background(),
|
||||
`SELECT id, bot_type, config::text FROM bots WHERE bot_type != ''`)
|
||||
if err != nil {
|
||||
r.logger.Error("failed to load bot configs", "error", err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var id, botType, configStr string
|
||||
if err := rows.Scan(&id, &botType, &configStr); err != nil {
|
||||
continue
|
||||
}
|
||||
r.Start(id, botType, json.RawMessage(configStr))
|
||||
}
|
||||
}
|
||||
|
||||
// Start starts a single bot by ID. Safe to call multiple times (restarts).
|
||||
func (r *Runner) Start(botID, botType string, config json.RawMessage) {
|
||||
r.mu.Lock()
|
||||
// Stop existing if running
|
||||
if cancel, ok := r.bots[botID]; ok {
|
||||
cancel()
|
||||
delete(r.bots, botID)
|
||||
}
|
||||
|
||||
fn, ok := r.types[botType]
|
||||
if !ok {
|
||||
r.mu.Unlock()
|
||||
r.logger.Warn("unknown bot type", "type", botType, "bot_id", botID)
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
r.bots[botID] = cancel
|
||||
r.mu.Unlock()
|
||||
|
||||
// Built-in bots pick a channel in config but users often skip "Add to Server".
|
||||
// Resolve channel_id → server and ensure bot_servers so send() doesn't no-op.
|
||||
r.ensureBotServerFromConfig(botID, config)
|
||||
|
||||
send := r.makeSender(botID)
|
||||
r.logger.Info("starting built-in bot", "bot_id", botID, "type", botType)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if rec := recover(); rec != nil {
|
||||
r.logger.Error("bot panic", "bot_id", botID, "type", botType, "panic", rec)
|
||||
}
|
||||
}()
|
||||
fn(ctx, r.db, config, send)
|
||||
r.logger.Info("bot stopped", "bot_id", botID, "type", botType)
|
||||
}()
|
||||
}
|
||||
|
||||
// ensureBotServerFromConfig joins the bot to the server that owns config.channel_id.
|
||||
func (r *Runner) ensureBotServerFromConfig(botID string, config json.RawMessage) {
|
||||
var cfg struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
}
|
||||
if err := json.Unmarshal(config, &cfg); err != nil || cfg.ChannelID == "" {
|
||||
return
|
||||
}
|
||||
serverID, err := r.hub.ServerIDForChannel(context.Background(), cfg.ChannelID)
|
||||
if err != nil || serverID == "" {
|
||||
r.logger.Warn("bot start: channel not found for auto-join", "bot_id", botID, "channel_id", cfg.ChannelID, "error", err)
|
||||
return
|
||||
}
|
||||
var ownerID string
|
||||
if err := r.db.QueryRowContext(context.Background(),
|
||||
`SELECT owner_id FROM bots WHERE id = $1`, botID,
|
||||
).Scan(&ownerID); err != nil {
|
||||
return
|
||||
}
|
||||
if _, err := r.db.ExecContext(context.Background(), `
|
||||
INSERT INTO bot_servers (bot_id, server_id, added_by)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT DO NOTHING
|
||||
`, botID, serverID, ownerID); err != nil {
|
||||
r.logger.Warn("bot start: auto-join server failed", "bot_id", botID, "server_id", serverID, "error", err)
|
||||
return
|
||||
}
|
||||
r.logger.Info("bot auto-joined server", "bot_id", botID, "server_id", serverID)
|
||||
}
|
||||
|
||||
// Stop stops a single bot by ID.
|
||||
func (r *Runner) Stop(botID string) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
if cancel, ok := r.bots[botID]; ok {
|
||||
cancel()
|
||||
delete(r.bots, botID)
|
||||
}
|
||||
}
|
||||
|
||||
// IsRunning checks if a bot is currently running.
|
||||
func (r *Runner) IsRunning(botID string) bool {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
_, ok := r.bots[botID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// makeSender returns a SendMessageFunc that inserts into DB and broadcasts.
|
||||
func (r *Runner) makeSender(botID string) SendMessageFunc {
|
||||
return func(channelID, content string) {
|
||||
if len(content) > 4000 {
|
||||
content = content[:4000]
|
||||
}
|
||||
|
||||
// Look up bot info + server
|
||||
var botName, ownerID string
|
||||
err := r.db.QueryRowContext(context.Background(),
|
||||
`SELECT name, owner_id FROM bots WHERE id = $1`, botID,
|
||||
).Scan(&botName, &ownerID)
|
||||
if err != nil {
|
||||
r.logger.Error("send: bot not found", "bot_id", botID, "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
serverID, err := r.hub.ServerIDForChannel(context.Background(), channelID)
|
||||
if err != nil {
|
||||
r.logger.Error("send: channel not found", "channel_id", channelID, "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Verify bot is in this server
|
||||
var inServer bool
|
||||
err = r.db.QueryRowContext(context.Background(),
|
||||
`SELECT EXISTS(SELECT 1 FROM bot_servers WHERE bot_id = $1 AND server_id = $2)`,
|
||||
botID, serverID,
|
||||
).Scan(&inServer)
|
||||
if err != nil || !inServer {
|
||||
r.logger.Warn("send: bot not in server", "bot_id", botID, "server_id", serverID)
|
||||
return
|
||||
}
|
||||
|
||||
var msgID, createdAt string
|
||||
err = r.db.QueryRowContext(context.Background(),
|
||||
`INSERT INTO messages (channel_id, author_id, content, bot_id)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, created_at::text`,
|
||||
channelID, ownerID, content, botID,
|
||||
).Scan(&msgID, &createdAt)
|
||||
if err != nil {
|
||||
r.logger.Error("send: insert failed", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
r.hub.BroadcastToServer(serverID, gateway.Event{
|
||||
Type: gateway.EventMessageCreate,
|
||||
Data: map[string]interface{}{
|
||||
"id": msgID,
|
||||
"channel_id": channelID,
|
||||
"author_id": ownerID,
|
||||
"author_username": botName,
|
||||
"author_display_name": nil,
|
||||
"author_bot": true,
|
||||
"bot_id": botID,
|
||||
"bot_name": botName,
|
||||
"content": content,
|
||||
"reply_to": nil,
|
||||
"edited_at": nil,
|
||||
"pinned": false,
|
||||
"created_at": createdAt,
|
||||
"embeds": []interface{}{},
|
||||
"reactions": []interface{}{},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// RegisteredTypes returns the list of available bot type names.
|
||||
func (r *Runner) RegisteredTypes() []string {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
names := make([]string, 0, len(r.types))
|
||||
for k := range r.types {
|
||||
names = append(names, k)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
// TryConfess intercepts "/confess …" at message create time.
|
||||
// On success the original is never stored or broadcast (true anonymity).
|
||||
// Returns the anonymous bot message payload for the HTTP response when handled.
|
||||
func (r *Runner) TryConfess(ctx context.Context, serverID, _authorID, content string) (map[string]interface{}, bool) {
|
||||
text, ok := parseConfessContent(content)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
var botID, botName, ownerID string
|
||||
var rawConfig string
|
||||
err := r.db.QueryRowContext(ctx, `
|
||||
SELECT b.id, b.name, b.owner_id, COALESCE(b.config::text, '{}')
|
||||
FROM bots b
|
||||
JOIN bot_servers bs ON bs.bot_id = b.id
|
||||
WHERE bs.server_id = $1 AND b.bot_type = 'confess'
|
||||
LIMIT 1
|
||||
`, serverID).Scan(&botID, &botName, &ownerID, &rawConfig)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
var cfg ConfessConfig
|
||||
if err := json.Unmarshal([]byte(rawConfig), &cfg); err != nil || cfg.ChannelID == "" {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Ensure bot can post to the confession channel's server.
|
||||
r.ensureBotServerFromConfig(botID, json.RawMessage(rawConfig))
|
||||
|
||||
anonContent := fmt.Sprintf("🕵️ **anonymous confession:** %s", text)
|
||||
if len(anonContent) > 4000 {
|
||||
anonContent = anonContent[:4000]
|
||||
}
|
||||
|
||||
var msgID, createdAt string
|
||||
err = r.db.QueryRowContext(ctx, `
|
||||
INSERT INTO messages (channel_id, author_id, content, bot_id)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, created_at::text
|
||||
`, cfg.ChannelID, ownerID, anonContent, botID).Scan(&msgID, &createdAt)
|
||||
if err != nil {
|
||||
r.logger.Error("confess: insert failed", "error", err)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
targetServerID, err := r.hub.ServerIDForChannel(ctx, cfg.ChannelID)
|
||||
if err != nil || targetServerID == "" {
|
||||
targetServerID = serverID
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"id": msgID,
|
||||
"channel_id": cfg.ChannelID,
|
||||
"author_id": ownerID,
|
||||
"author_username": botName,
|
||||
"author_display_name": nil,
|
||||
"author_bot": true,
|
||||
"bot_id": botID,
|
||||
"bot_name": botName,
|
||||
"content": anonContent,
|
||||
"reply_to": nil,
|
||||
"edited_at": nil,
|
||||
"pinned": false,
|
||||
"created_at": createdAt,
|
||||
"embeds": []interface{}{},
|
||||
"reactions": []interface{}{},
|
||||
}
|
||||
|
||||
r.hub.BroadcastToServer(targetServerID, gateway.Event{
|
||||
Type: gateway.EventMessageCreate,
|
||||
Data: payload,
|
||||
})
|
||||
|
||||
return payload, true
|
||||
}
|
||||
|
||||
// DeleteMessage removes a message and broadcasts MESSAGE_DELETE to live clients.
|
||||
func (r *Runner) DeleteMessage(messageID string) {
|
||||
var channelID string
|
||||
err := r.db.QueryRowContext(context.Background(),
|
||||
`DELETE FROM messages WHERE id = $1::uuid RETURNING channel_id`, messageID,
|
||||
).Scan(&channelID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
serverID, err := r.hub.ServerIDForChannel(context.Background(), channelID)
|
||||
if err != nil || serverID == "" {
|
||||
return
|
||||
}
|
||||
r.hub.BroadcastToServer(serverID, gateway.Event{
|
||||
Type: gateway.EventMessageDelete,
|
||||
Data: map[string]string{
|
||||
"id": messageID,
|
||||
"message_id": messageID,
|
||||
"channel_id": channelID,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SteamFreeConfig is the config shape for bot_type "steamfree".
|
||||
type SteamFreeConfig struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
PollMinutes int `json:"poll_minutes"`
|
||||
}
|
||||
|
||||
// SteamFreeBot polls Steam's featured categories for 100%-off games.
|
||||
func SteamFreeBot(ctx context.Context, _ *sql.DB, raw json.RawMessage, send SendMessageFunc) {
|
||||
var cfg SteamFreeConfig
|
||||
if err := json.Unmarshal(raw, &cfg); err != nil || cfg.ChannelID == "" {
|
||||
return
|
||||
}
|
||||
if cfg.PollMinutes <= 0 {
|
||||
cfg.PollMinutes = 30
|
||||
}
|
||||
|
||||
seen := map[int]bool{}
|
||||
ticker := time.NewTicker(time.Duration(cfg.PollMinutes) * time.Minute)
|
||||
defer ticker.Stop()
|
||||
|
||||
// Poll immediately on start
|
||||
pollSteam(cfg.ChannelID, seen, send)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
pollSteam(cfg.ChannelID, seen, send)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pollSteam(channelID string, seen map[int]bool, send SendMessageFunc) {
|
||||
games, err := fetchFreeGames()
|
||||
if err != nil {
|
||||
return // ponytail: silent on error, logs add noise
|
||||
}
|
||||
for _, g := range games {
|
||||
if seen[g.ID] {
|
||||
continue
|
||||
}
|
||||
seen[g.ID] = true
|
||||
|
||||
msg := fmt.Sprintf(
|
||||
"🎮 **FREE ON STEAM** 🎮\n**%s**\n~~$%.2f~~ → **FREE**\nhttps://store.steampowered.com/app/%d",
|
||||
g.Name, float64(g.OriginalPrice)/100, g.ID,
|
||||
)
|
||||
send(channelID, msg)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
type featuredCategories struct {
|
||||
Specials struct {
|
||||
Items []struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DiscountPct int `json:"discount_percent"`
|
||||
FinalPrice int `json:"final_price"`
|
||||
OriginalPrice int `json:"original_price"`
|
||||
} `json:"items"`
|
||||
} `json:"specials"`
|
||||
}
|
||||
|
||||
func fetchFreeGames() ([]struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DiscountPct int `json:"discount_percent"`
|
||||
FinalPrice int `json:"final_price"`
|
||||
OriginalPrice int `json:"original_price"`
|
||||
}, error) {
|
||||
client := &http.Client{Timeout: 15 * time.Second}
|
||||
resp, err := client.Get("https://store.steampowered.com/api/featuredcategories?cc=us&l=english")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("steam: %d", resp.StatusCode)
|
||||
}
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var cats featuredCategories
|
||||
if err := json.Unmarshal(body, &cats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var free []struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
DiscountPct int `json:"discount_percent"`
|
||||
FinalPrice int `json:"final_price"`
|
||||
OriginalPrice int `json:"original_price"`
|
||||
}
|
||||
for _, item := range cats.Specials.Items {
|
||||
if item.DiscountPct == 100 && item.OriginalPrice > 0 {
|
||||
free = append(free, item)
|
||||
}
|
||||
}
|
||||
return free, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ type createEventRequest struct {
|
||||
Color *string `json:"color"`
|
||||
}
|
||||
|
||||
func (h *Handler) RegisterCalendarRoutes(r chi.Router) {
|
||||
func (h *Handler) registerCalendarRoutes(r chi.Router) {
|
||||
r.Get("/{channelID}/events", h.ListEvents)
|
||||
r.Post("/{channelID}/events", h.CreateEvent)
|
||||
r.Patch("/events/{eventID}", h.UpdateEvent)
|
||||
|
||||
@@ -27,8 +27,11 @@ func (h *Handler) RegisterRoutes(r chi.Router) {
|
||||
r.Get("/{channelID}", h.Get)
|
||||
r.Patch("/{channelID}", h.Update)
|
||||
r.Delete("/{channelID}", h.Delete)
|
||||
// ponytail: thread + forum routes registered at top level in main.go to match frontend paths
|
||||
h.RegisterCalendarRoutes(r)
|
||||
r.Post("/{channelID}/threads", h.CreateThread)
|
||||
r.Get("/{channelID}/threads", h.ListThreads)
|
||||
r.Patch("/threads/{threadID}", h.UpdateThread)
|
||||
h.registerForumRoutes(r)
|
||||
h.registerCalendarRoutes(r)
|
||||
h.registerDocRoutes(r)
|
||||
h.registerListRoutes(r)
|
||||
h.registerOverrideRoutes(r)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/config"
|
||||
|
||||
@@ -25,11 +24,6 @@ func New(cfg *config.Config) (*DB, error) {
|
||||
return nil, fmt.Errorf("ping database: %w", err)
|
||||
}
|
||||
|
||||
// ponytail: prevent unbounded connection growth under burst load
|
||||
db.SetMaxOpenConns(25)
|
||||
db.SetMaxIdleConns(5)
|
||||
db.SetConnMaxLifetime(15 * time.Minute)
|
||||
|
||||
return &DB{db}, nil
|
||||
}
|
||||
|
||||
@@ -571,14 +565,5 @@ CREATE TABLE IF NOT EXISTS feature_request_votes (
|
||||
PRIMARY KEY (feature_request_id, user_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_feature_request_votes_fr ON feature_request_votes(feature_request_id);
|
||||
|
||||
-- Bot messages: track which bot authored a message
|
||||
ALTER TABLE messages ADD COLUMN IF NOT EXISTS bot_id UUID REFERENCES bots(id) ON DELETE SET NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_bot ON messages(bot_id) WHERE bot_id IS NOT NULL;
|
||||
|
||||
-- Built-in bot types: bot_type + config for server-managed bots
|
||||
ALTER TABLE bots ADD COLUMN IF NOT EXISTS bot_type VARCHAR(32) DEFAULT '';
|
||||
ALTER TABLE bots ADD COLUMN IF NOT EXISTS config JSONB DEFAULT '{}';
|
||||
CREATE INDEX IF NOT EXISTS idx_bots_type ON bots(bot_type) WHERE bot_type != '';
|
||||
`
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
@@ -108,9 +106,6 @@ type Client struct {
|
||||
Conn *websocket.Conn
|
||||
UserID string
|
||||
Username string
|
||||
IsBot bool
|
||||
BotID string
|
||||
BotName string
|
||||
send chan []byte
|
||||
}
|
||||
|
||||
@@ -160,18 +155,6 @@ func (c *Client) readPump() {
|
||||
c.Hub.BroadcastEvent(Event{Type: event.Type, Data: data})
|
||||
case EventPresenceUpdate:
|
||||
c.Hub.BroadcastEvent(event)
|
||||
case EventVoiceJoin, EventVoiceLeave, EventVoiceMute, EventVoiceDeafen:
|
||||
// Broadcast voice state changes to all clients with sender info
|
||||
var vData map[string]interface{}
|
||||
if raw, ok := event.Data.(json.RawMessage); ok {
|
||||
json.Unmarshal(raw, &vData)
|
||||
}
|
||||
if vData == nil {
|
||||
vData = make(map[string]interface{})
|
||||
}
|
||||
vData["user_id"] = c.UserID
|
||||
vData["username"] = c.Username
|
||||
c.Hub.BroadcastEvent(Event{Type: event.Type, Data: vData})
|
||||
case EventVoiceWhisper:
|
||||
// Forward voice whispers only to the target user, not broadcast
|
||||
var whisperData struct {
|
||||
@@ -189,18 +172,6 @@ func (c *Client) readPump() {
|
||||
})
|
||||
}
|
||||
}
|
||||
case BotSendMessage:
|
||||
if !c.IsBot {
|
||||
c.Hub.logger.Warn("non-bot client sent SEND_MESSAGE", "user_id", c.UserID)
|
||||
continue
|
||||
}
|
||||
c.handleBotSendMessage(event.Data)
|
||||
case BotDeleteMessage:
|
||||
if !c.IsBot {
|
||||
c.Hub.logger.Warn("non-bot client sent DELETE_MESSAGE", "user_id", c.UserID)
|
||||
continue
|
||||
}
|
||||
c.handleBotDeleteMessage(event.Data)
|
||||
default:
|
||||
c.Hub.logger.Info("received event from client", "type", event.Type, "user_id", c.UserID)
|
||||
}
|
||||
@@ -317,195 +288,3 @@ func ServeWS(db *sql.DB, hub *Hub, logger *slog.Logger, w http.ResponseWriter, r
|
||||
go client.writePump()
|
||||
go client.readPump()
|
||||
}
|
||||
|
||||
// ServeBotWS handles websocket requests from bot clients.
|
||||
// Authenticates via ?token= query param (bot token, hashed lookup).
|
||||
func ServeBotWS(db *sql.DB, hub *Hub, logger *slog.Logger, w http.ResponseWriter, r *http.Request) {
|
||||
token := r.URL.Query().Get("token")
|
||||
if token == "" {
|
||||
http.Error(w, `{"error":"token query param required"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// Hash the token and look up the bot.
|
||||
tokenHash := hashToken(token)
|
||||
|
||||
var botID, botName, ownerID string
|
||||
err := db.QueryRowContext(r.Context(),
|
||||
`SELECT id, name, owner_id FROM bots WHERE token = $1`,
|
||||
tokenHash,
|
||||
).Scan(&botID, &botName, &ownerID)
|
||||
if err != nil {
|
||||
logger.Warn("bot ws auth: invalid token")
|
||||
http.Error(w, `{"error":"invalid bot token"}`, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
// Verify the bot is added to at least one server.
|
||||
var serverCount int
|
||||
err = db.QueryRowContext(r.Context(),
|
||||
`SELECT COUNT(*) FROM bot_servers WHERE bot_id = $1`, botID,
|
||||
).Scan(&serverCount)
|
||||
if err != nil || serverCount == 0 {
|
||||
logger.Warn("bot ws auth: bot not added to any server", "bot_id", botID)
|
||||
http.Error(w, `{"error":"bot not added to any server"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
logger.Error("bot websocket upgrade failed", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Load bot server memberships into hub so BroadcastToServer works.
|
||||
hub.RefreshUserServers(ownerID)
|
||||
|
||||
conn.SetReadDeadline(time.Time{})
|
||||
conn.WriteMessage(websocket.TextMessage, []byte(`{"type":"ready","bot_id":"`+botID+`"}`))
|
||||
|
||||
client := &Client{
|
||||
Hub: hub,
|
||||
Conn: conn,
|
||||
UserID: ownerID,
|
||||
Username: botName,
|
||||
IsBot: true,
|
||||
BotID: botID,
|
||||
BotName: botName,
|
||||
send: make(chan []byte, 256),
|
||||
}
|
||||
|
||||
hub.Register(client)
|
||||
|
||||
go client.writePump()
|
||||
go client.readPump()
|
||||
}
|
||||
|
||||
// hashToken returns the SHA-256 hex digest of a token.
|
||||
func hashToken(token string) string {
|
||||
h := sha256.Sum256([]byte(token))
|
||||
return hex.EncodeToString(h[:])
|
||||
}
|
||||
|
||||
// handleBotSendMessage processes a SEND_MESSAGE action from a bot client.
|
||||
func (c *Client) handleBotSendMessage(data interface{}) {
|
||||
var payload struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
raw, ok := data.(json.RawMessage)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(raw, &payload); err != nil || payload.ChannelID == "" || payload.Content == "" {
|
||||
c.Hub.logger.Warn("bot SEND_MESSAGE: invalid payload")
|
||||
return
|
||||
}
|
||||
if len(payload.Content) > 4000 {
|
||||
payload.Content = payload.Content[:4000]
|
||||
}
|
||||
|
||||
// Verify the bot is in the server that owns this channel.
|
||||
serverID, err := c.Hub.ServerIDForChannel(context.Background(), payload.ChannelID)
|
||||
if err != nil {
|
||||
c.Hub.logger.Warn("bot SEND_MESSAGE: channel not found", "channel_id", payload.ChannelID)
|
||||
return
|
||||
}
|
||||
var inServer bool
|
||||
err = c.Hub.db.QueryRowContext(context.Background(),
|
||||
`SELECT EXISTS(SELECT 1 FROM bot_servers WHERE bot_id = $1 AND server_id = $2)`,
|
||||
c.BotID, serverID,
|
||||
).Scan(&inServer)
|
||||
if err != nil || !inServer {
|
||||
c.Hub.logger.Warn("bot SEND_MESSAGE: bot not in server", "bot_id", c.BotID, "server_id", serverID)
|
||||
return
|
||||
}
|
||||
|
||||
// Insert the message with bot_id set.
|
||||
var msgID, createdAt string
|
||||
err = c.Hub.db.QueryRowContext(context.Background(),
|
||||
`INSERT INTO messages (channel_id, author_id, content, bot_id)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, created_at::text`,
|
||||
payload.ChannelID, c.UserID, payload.Content, c.BotID,
|
||||
).Scan(&msgID, &createdAt)
|
||||
if err != nil {
|
||||
c.Hub.logger.Error("bot SEND_MESSAGE: insert failed", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Broadcast MESSAGE_CREATE to the server.
|
||||
c.Hub.BroadcastToServer(serverID, Event{
|
||||
Type: EventMessageCreate,
|
||||
Data: map[string]interface{}{
|
||||
"id": msgID,
|
||||
"channel_id": payload.ChannelID,
|
||||
"author_id": c.UserID,
|
||||
"author_username": c.BotName,
|
||||
"author_display_name": nil,
|
||||
"author_bot": true,
|
||||
"bot_id": c.BotID,
|
||||
"bot_name": c.BotName,
|
||||
"content": payload.Content,
|
||||
"reply_to": nil,
|
||||
"edited_at": nil,
|
||||
"pinned": false,
|
||||
"created_at": createdAt,
|
||||
"embeds": []interface{}{},
|
||||
"reactions": []interface{}{},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// handleBotDeleteMessage processes a DELETE_MESSAGE action from a bot client.
|
||||
func (c *Client) handleBotDeleteMessage(data interface{}) {
|
||||
var payload struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
MessageID string `json:"message_id"`
|
||||
}
|
||||
raw, ok := data.(json.RawMessage)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(raw, &payload); err != nil || payload.ChannelID == "" || payload.MessageID == "" {
|
||||
c.Hub.logger.Warn("bot DELETE_MESSAGE: invalid payload")
|
||||
return
|
||||
}
|
||||
|
||||
// Verify the bot is in the server that owns this channel.
|
||||
serverID, err := c.Hub.ServerIDForChannel(context.Background(), payload.ChannelID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var inServer bool
|
||||
err = c.Hub.db.QueryRowContext(context.Background(),
|
||||
`SELECT EXISTS(SELECT 1 FROM bot_servers WHERE bot_id = $1 AND server_id = $2)`,
|
||||
c.BotID, serverID,
|
||||
).Scan(&inServer)
|
||||
if err != nil || !inServer {
|
||||
return
|
||||
}
|
||||
|
||||
// Delete the message (only if it exists in this channel).
|
||||
result, err := c.Hub.db.ExecContext(context.Background(),
|
||||
`DELETE FROM messages WHERE id = $1 AND channel_id = $2`,
|
||||
payload.MessageID, payload.ChannelID,
|
||||
)
|
||||
if err != nil {
|
||||
c.Hub.logger.Error("bot DELETE_MESSAGE: delete failed", "error", err)
|
||||
return
|
||||
}
|
||||
rows, _ := result.RowsAffected()
|
||||
if rows == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Broadcast MESSAGE_DELETE.
|
||||
c.Hub.BroadcastToServer(serverID, Event{
|
||||
Type: EventMessageDelete,
|
||||
Data: map[string]string{
|
||||
"id": payload.MessageID,
|
||||
"channel_id": payload.ChannelID,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@ const (
|
||||
EventVoiceMute = "VOICE_MUTE"
|
||||
EventVoiceDeafen = "VOICE_DEAFEN"
|
||||
EventVoiceWhisper = "VOICE_WHISPER"
|
||||
|
||||
// Bot action events (sent by bot clients)
|
||||
BotSendMessage = "SEND_MESSAGE"
|
||||
BotDeleteMessage = "DELETE_MESSAGE"
|
||||
)
|
||||
|
||||
// Event represents a WebSocket event sent to clients.
|
||||
|
||||
@@ -27,13 +27,6 @@ type Handler struct {
|
||||
pushHandler *push.Handler
|
||||
logger *slog.Logger
|
||||
checker *permissions.Checker
|
||||
// Optional: intercepts /confess so the original message is never stored/broadcast.
|
||||
confess ConfessHandler
|
||||
}
|
||||
|
||||
// ConfessHandler posts an anonymous confession and returns the bot message payload.
|
||||
type ConfessHandler interface {
|
||||
TryConfess(ctx context.Context, serverID, authorID, content string) (payload map[string]interface{}, handled bool)
|
||||
}
|
||||
|
||||
func NewHandler(db *sql.DB, hub *gateway.Hub, pushHandler *push.Handler, logger *slog.Logger, checker *permissions.Checker) *Handler {
|
||||
@@ -47,11 +40,6 @@ func NewHandler(db *sql.DB, hub *gateway.Hub, pushHandler *push.Handler, logger
|
||||
}
|
||||
}
|
||||
|
||||
// SetConfessHandler wires the built-in confess interceptor (optional).
|
||||
func (h *Handler) SetConfessHandler(c ConfessHandler) {
|
||||
h.confess = c
|
||||
}
|
||||
|
||||
func (h *Handler) RegisterRoutes(r chi.Router) {
|
||||
r.Get("/", h.List)
|
||||
r.Post("/", h.Create)
|
||||
@@ -131,7 +119,6 @@ func (h *Handler) BulkDelete(w http.ResponseWriter, r *http.Request) {
|
||||
Type: gateway.EventMessageDelete,
|
||||
Data: map[string]string{
|
||||
"id": id,
|
||||
"message_id": id,
|
||||
"channel_id": channelID,
|
||||
},
|
||||
})
|
||||
@@ -172,9 +159,6 @@ type messageResponse struct {
|
||||
AuthorID string `json:"author_id"`
|
||||
AuthorName string `json:"author_username"`
|
||||
DisplayName *string `json:"author_display_name"`
|
||||
AuthorBot bool `json:"author_bot"`
|
||||
BotID *string `json:"bot_id,omitempty"`
|
||||
BotName *string `json:"bot_name,omitempty"`
|
||||
Content string `json:"content"`
|
||||
ReplyTo *string `json:"reply_to,omitempty"`
|
||||
EditedAt *string `json:"edited_at"`
|
||||
@@ -256,29 +240,6 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Gate @everyone / @channel on MENTION_EVERYONE (owner/admin always pass).
|
||||
if hasBroadcastToken(req.Content, "everyone") || hasBroadcastToken(req.Content, "channel") {
|
||||
allowed, permErr := h.checker.CheckPermission(r.Context(), serverID, userID, permissions.MENTION_EVERYONE)
|
||||
if permErr != nil {
|
||||
http.Error(w, `{"error":"server error"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if !allowed {
|
||||
http.Error(w, `{"error":"missing permission: MENTION_EVERYONE"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Anonymous confessions: never store/broadcast the original /confess message.
|
||||
if h.confess != nil {
|
||||
if payload, handled := h.confess.TryConfess(r.Context(), serverID, userID, req.Content); handled {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
json.NewEncoder(w).Encode(payload)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var msg messageResponse
|
||||
var editedAt sql.NullString
|
||||
var createdAt sql.NullString
|
||||
@@ -503,7 +464,6 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
Type: gateway.EventMessageDelete,
|
||||
Data: map[string]string{
|
||||
"id": messageID,
|
||||
"message_id": messageID,
|
||||
"channel_id": channelID,
|
||||
},
|
||||
})
|
||||
@@ -545,20 +505,18 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
if before != "" {
|
||||
rows, err = h.db.QueryContext(r.Context(), `
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text, m.bot_id, b.name
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text
|
||||
FROM messages m
|
||||
JOIN users u ON m.author_id = u.id
|
||||
LEFT JOIN bots b ON m.bot_id = b.id
|
||||
WHERE m.channel_id = $1 AND m.created_at < (SELECT created_at FROM messages WHERE id = $2)
|
||||
ORDER BY m.created_at DESC
|
||||
LIMIT $3
|
||||
`, channelID, before, limit)
|
||||
} else {
|
||||
rows, err = h.db.QueryContext(r.Context(), `
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text, m.bot_id, b.name
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text
|
||||
FROM messages m
|
||||
JOIN users u ON m.author_id = u.id
|
||||
LEFT JOIN bots b ON m.bot_id = b.id
|
||||
WHERE m.channel_id = $1
|
||||
ORDER BY m.created_at DESC
|
||||
LIMIT $2
|
||||
@@ -576,9 +534,7 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
||||
var editedAt sql.NullString
|
||||
var createdAt sql.NullString
|
||||
var replyTo sql.NullString
|
||||
var botID sql.NullString
|
||||
var botName sql.NullString
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt, &botID, &botName)
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -588,13 +544,6 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
||||
if editedAt.Valid {
|
||||
msg.EditedAt = &editedAt.String
|
||||
}
|
||||
if botID.Valid {
|
||||
msg.BotID = &botID.String
|
||||
msg.AuthorBot = true
|
||||
}
|
||||
if botName.Valid {
|
||||
msg.BotName = &botName.String
|
||||
}
|
||||
msg.CreatedAt = createdAt.String
|
||||
messages = append(messages, msg)
|
||||
}
|
||||
@@ -853,10 +802,9 @@ func (h *Handler) Search(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
rows, err := h.db.QueryContext(r.Context(), `
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text,
|
||||
ts_rank(m.search_vector, plainto_tsquery('english', $2)) AS rank, m.bot_id, b.name
|
||||
ts_rank(m.search_vector, plainto_tsquery('english', $2)) AS rank
|
||||
FROM messages m
|
||||
JOIN users u ON m.author_id = u.id
|
||||
LEFT JOIN bots b ON m.bot_id = b.id
|
||||
WHERE m.channel_id = $1 AND m.search_vector @@ plainto_tsquery('english', $2)
|
||||
ORDER BY rank DESC, m.created_at DESC
|
||||
LIMIT $3
|
||||
@@ -874,9 +822,7 @@ func (h *Handler) Search(w http.ResponseWriter, r *http.Request) {
|
||||
var createdAt sql.NullString
|
||||
var replyTo sql.NullString
|
||||
var rank float64
|
||||
var botID sql.NullString
|
||||
var botName sql.NullString
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt, &rank, &botID, &botName)
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt, &rank)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -886,13 +832,6 @@ func (h *Handler) Search(w http.ResponseWriter, r *http.Request) {
|
||||
if editedAt.Valid {
|
||||
msg.EditedAt = &editedAt.String
|
||||
}
|
||||
if botID.Valid {
|
||||
msg.BotID = &botID.String
|
||||
msg.AuthorBot = true
|
||||
}
|
||||
if botName.Valid {
|
||||
msg.BotName = &botName.String
|
||||
}
|
||||
msg.CreatedAt = createdAt.String
|
||||
messages = append(messages, msg)
|
||||
}
|
||||
@@ -1120,10 +1059,9 @@ func (h *Handler) ListPinned(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
rows, err := h.db.QueryContext(r.Context(), `
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text, m.bot_id, b.name
|
||||
SELECT m.id, m.channel_id, m.author_id, u.username, u.display_name, m.content, m.reply_to::text, m.edited_at::text, m.pinned, m.created_at::text
|
||||
FROM messages m
|
||||
JOIN users u ON m.author_id = u.id
|
||||
LEFT JOIN bots b ON m.bot_id = b.id
|
||||
WHERE m.channel_id = $1 AND m.pinned = TRUE
|
||||
ORDER BY m.created_at DESC
|
||||
`, channelID)
|
||||
@@ -1139,9 +1077,7 @@ func (h *Handler) ListPinned(w http.ResponseWriter, r *http.Request) {
|
||||
var editedAt sql.NullString
|
||||
var createdAt sql.NullString
|
||||
var replyTo sql.NullString
|
||||
var botID sql.NullString
|
||||
var botName sql.NullString
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt, &botID, &botName)
|
||||
err := rows.Scan(&msg.ID, &msg.ChannelID, &msg.AuthorID, &msg.AuthorName, &msg.DisplayName, &msg.Content, &replyTo, &editedAt, &msg.Pinned, &createdAt)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -1151,13 +1087,6 @@ func (h *Handler) ListPinned(w http.ResponseWriter, r *http.Request) {
|
||||
if editedAt.Valid {
|
||||
msg.EditedAt = &editedAt.String
|
||||
}
|
||||
if botID.Valid {
|
||||
msg.BotID = &botID.String
|
||||
msg.AuthorBot = true
|
||||
}
|
||||
if botName.Valid {
|
||||
msg.BotName = &botName.String
|
||||
}
|
||||
msg.CreatedAt = createdAt.String
|
||||
messages = append(messages, msg)
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@ import (
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"git.dustin.coffee/hobokenchicken/dumpsterChat/internal/push"
|
||||
)
|
||||
|
||||
var mentionRegex = regexp.MustCompile(`<@([0-9a-f-]+)>`)
|
||||
var everyoneMention = "@everyone"
|
||||
var roleMentionRegex = regexp.MustCompile(`<@&([0-9a-f-]+)>`)
|
||||
var plainUsernameMention = regexp.MustCompile(`@([a-zA-Z0-9_.-]+)`)
|
||||
|
||||
// MentionHandler dispatches push notifications for @mentions.
|
||||
type MentionHandler struct {
|
||||
@@ -30,40 +29,20 @@ func NewMentionHandler(db *sql.DB, pushHandler *push.Handler, logger *slog.Logge
|
||||
}
|
||||
}
|
||||
|
||||
// hasBroadcastToken reports whether content contains @everyone / @channel as a whole token.
|
||||
func hasBroadcastToken(content, token string) bool {
|
||||
// token like "everyone" or "channel" (without @)
|
||||
needle := "@" + token
|
||||
idx := 0
|
||||
for {
|
||||
i := strings.Index(strings.ToLower(content[idx:]), needle)
|
||||
if i < 0 {
|
||||
return false
|
||||
}
|
||||
i += idx
|
||||
end := i + len(needle)
|
||||
if end >= len(content) || !isUsernameChar(rune(content[end])) {
|
||||
return true
|
||||
}
|
||||
idx = end
|
||||
}
|
||||
}
|
||||
|
||||
func isUsernameChar(r rune) bool {
|
||||
return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' || r == '.' || r == '-'
|
||||
}
|
||||
|
||||
// ParseAndNotify parses message content for mentions and sends push notifications.
|
||||
func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID, content string) {
|
||||
// Find individual user mentions
|
||||
userMatches := mentionRegex.FindAllStringSubmatch(content, -1)
|
||||
mentionedUsers := make(map[string]bool)
|
||||
|
||||
// Discord-style ID mentions
|
||||
for _, match := range mentionRegex.FindAllStringSubmatch(content, -1) {
|
||||
for _, match := range userMatches {
|
||||
if len(match) > 1 {
|
||||
mentionedUsers[match[1]] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Check for @everyone
|
||||
isEveryone := strings.Contains(content, everyoneMention)
|
||||
|
||||
// Get channel info for notification
|
||||
var serverID, channelName string
|
||||
err := m.db.QueryRowContext(ctx,
|
||||
@@ -96,9 +75,8 @@ func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID
|
||||
"url": "/channels/" + channelID,
|
||||
}
|
||||
|
||||
// @everyone / @channel — fan out to server members (permission gated at create).
|
||||
// ponytail: both use the same fanout; UI labels differ. Split if channel-private members matter.
|
||||
if hasBroadcastToken(content, "everyone") || hasBroadcastToken(content, "channel") {
|
||||
if isEveryone {
|
||||
// Send to all server members except those who muted this channel
|
||||
rows, err := m.db.QueryContext(ctx,
|
||||
`SELECT m.user_id FROM members m
|
||||
LEFT JOIN notification_settings ns ON ns.user_id = m.user_id AND ns.channel_id = $3
|
||||
@@ -107,7 +85,7 @@ func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID
|
||||
serverID, authorID, channelID,
|
||||
)
|
||||
if err != nil {
|
||||
m.logger.Error("failed to query server members for broadcast mention", "error", err)
|
||||
m.logger.Error("failed to query server members for @everyone", "error", err)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -122,43 +100,13 @@ func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID
|
||||
return
|
||||
}
|
||||
|
||||
// Plain @username mentions (what the frontend actually stores)
|
||||
usernames := make([]string, 0)
|
||||
seenUsernames := make(map[string]bool)
|
||||
for _, match := range plainUsernameMention.FindAllStringSubmatch(content, -1) {
|
||||
if len(match) < 2 {
|
||||
continue
|
||||
}
|
||||
u := strings.ToLower(match[1])
|
||||
if u == "everyone" || u == "channel" || u == "here" {
|
||||
continue
|
||||
}
|
||||
if !seenUsernames[u] {
|
||||
seenUsernames[u] = true
|
||||
usernames = append(usernames, match[1])
|
||||
}
|
||||
}
|
||||
if len(usernames) > 0 {
|
||||
// Resolve usernames that are members of this server.
|
||||
for _, uname := range usernames {
|
||||
var uid string
|
||||
err := m.db.QueryRowContext(ctx, `
|
||||
SELECT u.id FROM users u
|
||||
JOIN members m ON m.user_id = u.id
|
||||
WHERE m.server_id = $1 AND LOWER(u.username) = LOWER($2)
|
||||
`, serverID, uname).Scan(&uid)
|
||||
if err == nil {
|
||||
mentionedUsers[uid] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Role mentions
|
||||
// Check for role mentions
|
||||
roleMatches := roleMentionRegex.FindAllStringSubmatch(content, -1)
|
||||
if len(roleMatches) > 0 {
|
||||
for _, match := range roleMatches {
|
||||
if len(match) > 1 {
|
||||
roleID := match[1]
|
||||
// Get users with this role
|
||||
rows, err := m.db.QueryContext(ctx,
|
||||
`SELECT user_id FROM member_roles WHERE role_id = $1 AND user_id != $2`,
|
||||
roleID, authorID,
|
||||
@@ -179,9 +127,12 @@ func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the author from mentions
|
||||
delete(mentionedUsers, authorID)
|
||||
|
||||
// Send push to individually mentioned users
|
||||
for userID := range mentionedUsers {
|
||||
// Check if user is in DND status
|
||||
var status string
|
||||
err := m.db.QueryRowContext(ctx,
|
||||
`SELECT COALESCE(status, 'online') FROM users WHERE id = $1`, userID,
|
||||
@@ -193,6 +144,7 @@ func (m *MentionHandler) ParseAndNotify(ctx context.Context, channelID, authorID
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if user muted this channel
|
||||
var level string
|
||||
err = m.db.QueryRowContext(ctx,
|
||||
`SELECT level FROM notification_settings WHERE user_id = $1 AND channel_id = $2`,
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package message
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHasBroadcastToken(t *testing.T) {
|
||||
cases := []struct {
|
||||
content string
|
||||
token string
|
||||
want bool
|
||||
}{
|
||||
{"hello @everyone", "everyone", true},
|
||||
{"@everyone hi", "everyone", true},
|
||||
{"@EVERYONE", "everyone", true},
|
||||
{"@everyone!", "everyone", true},
|
||||
{"@everyoneelse", "everyone", false},
|
||||
{"noteveryone", "everyone", false},
|
||||
{"@channel", "channel", true},
|
||||
{"ping @channel please", "channel", true},
|
||||
{"@channeling", "channel", false},
|
||||
{"", "everyone", false},
|
||||
{"@", "everyone", false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := hasBroadcastToken(tc.content, tc.token)
|
||||
if got != tc.want {
|
||||
t.Errorf("hasBroadcastToken(%q, %q) = %v, want %v", tc.content, tc.token, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsUsernameChar(t *testing.T) {
|
||||
if !isUsernameChar('a') || !isUsernameChar('9') || !isUsernameChar('_') {
|
||||
t.Fatal("expected alnum/_")
|
||||
}
|
||||
if isUsernameChar(' ') || isUsernameChar('!') || isUsernameChar('@') {
|
||||
t.Fatal("unexpected username chars")
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
@@ -13,21 +12,16 @@ import (
|
||||
type ipLimiter struct {
|
||||
mu sync.Mutex
|
||||
limiters map[string]*rate.Limiter
|
||||
lastUsed map[string]time.Time
|
||||
rate rate.Limit
|
||||
burst int
|
||||
}
|
||||
|
||||
func newIPLimiter(r rate.Limit, burst int) *ipLimiter {
|
||||
l := &ipLimiter{
|
||||
return &ipLimiter{
|
||||
limiters: make(map[string]*rate.Limiter),
|
||||
lastUsed: make(map[string]time.Time),
|
||||
rate: r,
|
||||
burst: burst,
|
||||
}
|
||||
// ponytail: evict inactive limiters every 5 minutes to prevent unbounded map growth
|
||||
go l.cleanup()
|
||||
return l
|
||||
}
|
||||
|
||||
func (l *ipLimiter) getLimiter(ip string) *rate.Limiter {
|
||||
@@ -39,27 +33,9 @@ func (l *ipLimiter) getLimiter(ip string) *rate.Limiter {
|
||||
lim = rate.NewLimiter(l.rate, l.burst)
|
||||
l.limiters[ip] = lim
|
||||
}
|
||||
l.lastUsed[ip] = time.Now()
|
||||
return lim
|
||||
}
|
||||
|
||||
// cleanup runs in a background goroutine and removes limiters that haven't
|
||||
// been accessed in 10 minutes.
|
||||
func (l *ipLimiter) cleanup() {
|
||||
for {
|
||||
time.Sleep(5 * time.Minute)
|
||||
l.mu.Lock()
|
||||
now := time.Now()
|
||||
for ip, last := range l.lastUsed {
|
||||
if now.Sub(last) > 10*time.Minute {
|
||||
delete(l.limiters, ip)
|
||||
delete(l.lastUsed, ip)
|
||||
}
|
||||
}
|
||||
l.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
// RateLimit returns middleware that limits requests per IP.
|
||||
// requestsPerSecond is the sustained rate, burst is the max burst size.
|
||||
func RateLimit(requestsPerSecond float64, burst int) func(http.Handler) http.Handler {
|
||||
|
||||
@@ -18,23 +18,13 @@ type SessionStore interface {
|
||||
func Session(store SessionStore, cfg *config.Config) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var token string
|
||||
cookie, err := r.Cookie(cfg.Session.CookieName)
|
||||
if err == nil {
|
||||
token = cookie.Value
|
||||
} else {
|
||||
authHeader := r.Header.Get("Authorization")
|
||||
if len(authHeader) > 7 && authHeader[:7] == "Bearer " {
|
||||
token = authHeader[7:]
|
||||
}
|
||||
}
|
||||
|
||||
if token == "" {
|
||||
if err != nil {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
userID, err := store.GetUserIDByToken(r.Context(), token)
|
||||
userID, err := store.GetUserIDByToken(r.Context(), cookie.Value)
|
||||
if err != nil {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package permissions
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHas(t *testing.T) {
|
||||
set := VIEW_CHANNEL | SEND_MESSAGES | MENTION_EVERYONE
|
||||
|
||||
if !Has(set, VIEW_CHANNEL) {
|
||||
t.Fatal("expected VIEW_CHANNEL")
|
||||
}
|
||||
if !Has(set, SEND_MESSAGES) {
|
||||
t.Fatal("expected SEND_MESSAGES")
|
||||
}
|
||||
if Has(set, KICK_MEMBERS) {
|
||||
t.Fatal("did not expect KICK_MEMBERS")
|
||||
}
|
||||
if !Has(set, VIEW_CHANNEL|SEND_MESSAGES) {
|
||||
t.Fatal("expected multi-bit all-present")
|
||||
}
|
||||
if Has(set, VIEW_CHANNEL|KICK_MEMBERS) {
|
||||
t.Fatal("multi-bit should require all bits")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdministratorBypassSemantics(t *testing.T) {
|
||||
// Client/backend convention: ADMINISTRATOR implies all gates when checked separately.
|
||||
if !Has(ADMINISTRATOR, ADMINISTRATOR) {
|
||||
t.Fatal("admin flag self")
|
||||
}
|
||||
// ADMINISTRATOR alone does not set other bits; Has is pure bit check.
|
||||
if Has(ADMINISTRATOR, KICK_MEMBERS) {
|
||||
t.Fatal("Has is not an admin-implies-all helper; CheckPermission does that")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultEveryoneDoesNotIncludeMentionEveryone(t *testing.T) {
|
||||
if Has(DefaultEveryonePermissions, MENTION_EVERYONE) {
|
||||
t.Fatal("@everyone default must not grant MENTION_EVERYONE")
|
||||
}
|
||||
if !Has(DefaultEveryonePermissions, SEND_MESSAGES) {
|
||||
t.Fatal("@everyone default should grant SEND_MESSAGES")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddRemove(t *testing.T) {
|
||||
p := int64(0)
|
||||
p = Add(p, VIEW_CHANNEL)
|
||||
p = Add(p, KICK_MEMBERS)
|
||||
if !Has(p, VIEW_CHANNEL|KICK_MEMBERS) {
|
||||
t.Fatal("Add failed")
|
||||
}
|
||||
p = Remove(p, KICK_MEMBERS)
|
||||
if Has(p, KICK_MEMBERS) {
|
||||
t.Fatal("Remove failed")
|
||||
}
|
||||
if !Has(p, VIEW_CHANNEL) {
|
||||
t.Fatal("Remove cleared wrong bit")
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,6 @@ type memberResponse struct {
|
||||
Avatar string `json:"avatar"`
|
||||
Status string `json:"status"`
|
||||
StatusText string `json:"status_text"`
|
||||
IsBot bool `json:"is_bot,omitempty"`
|
||||
BotType string `json:"bot_type,omitempty"`
|
||||
}
|
||||
|
||||
func (h *MemberHandler) ListMembers(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -84,28 +82,6 @@ func (h *MemberHandler) ListMembers(w http.ResponseWriter, r *http.Request) {
|
||||
members = append(members, m)
|
||||
}
|
||||
|
||||
// Bots added to this server (separate BOTS section in the member list).
|
||||
botRows, err := h.db.QueryContext(r.Context(), `
|
||||
SELECT b.id, b.name, COALESCE(b.avatar, ''), COALESCE(b.bot_type, '')
|
||||
FROM bot_servers bs
|
||||
JOIN bots b ON b.id = bs.bot_id
|
||||
WHERE bs.server_id = $1
|
||||
ORDER BY b.name
|
||||
`, serverID)
|
||||
if err == nil {
|
||||
defer botRows.Close()
|
||||
for botRows.Next() {
|
||||
var m memberResponse
|
||||
if err := botRows.Scan(&m.ID, &m.Username, &m.Avatar, &m.BotType); err != nil {
|
||||
continue
|
||||
}
|
||||
m.DisplayName = m.Username
|
||||
m.Status = "online" // ponytail: no bot presence yet; always show online
|
||||
m.IsBot = true
|
||||
members = append(members, m)
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(members)
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "629643353973",
|
||||
"project_id": "dumpster-chat",
|
||||
"storage_bucket": "dumpster-chat.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:629643353973:android:29dcc703959dd306c0fd3c",
|
||||
"android_client_info": {
|
||||
"package_name": "coffee.dustin.dumpster"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDt3h4G-imzD7IedRqYOUBIv8CtZQT2YyA"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@@ -1,40 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="gruvbox">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<script>
|
||||
// Apply saved theme before paint (migrates legacy light/dark).
|
||||
(function () {
|
||||
try {
|
||||
var t = localStorage.getItem('dumpster-theme');
|
||||
if (t === 'light') t = 'gruvbox-light';
|
||||
else if (t === 'dark' || !t) t = 'gruvbox';
|
||||
var ok = {
|
||||
gruvbox: 1,
|
||||
'gruvbox-light': 1,
|
||||
'one-dark': 1,
|
||||
dracula: 1,
|
||||
nord: 1,
|
||||
'tokyo-night': 1,
|
||||
catppuccin: 1,
|
||||
'solarized-dark': 1,
|
||||
monokai: 1,
|
||||
'github-dark': 1,
|
||||
};
|
||||
if (!ok[t]) t = 'gruvbox';
|
||||
document.documentElement.setAttribute('data-theme', t);
|
||||
document.documentElement.classList.add(t === 'gruvbox-light' ? 'light' : 'dark');
|
||||
} catch (e) {
|
||||
document.documentElement.setAttribute('data-theme', 'gruvbox');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<!-- PWA Meta Tags -->
|
||||
<meta name="theme-color" content="#282828" media="(prefers-color-scheme: dark)" />
|
||||
<meta name="theme-color" content="#282828" />
|
||||
<meta name="color-scheme" content="dark light" />
|
||||
<meta name="color-scheme" content="dark" />
|
||||
<meta name="description" content="A chaotic, self-hosted Discord-like platform" />
|
||||
|
||||
<!-- Apple -->
|
||||
@@ -60,20 +33,11 @@
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
<script>
|
||||
// Register service worker (only for web, avoid in Tauri to prevent 404 cache bugs)
|
||||
// Register service worker
|
||||
if ('serviceWorker' in navigator) {
|
||||
if (!('__TAURI_INTERNALS__' in window) && !('__TAURI__' in window)) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js').catch(() => {});
|
||||
});
|
||||
} else {
|
||||
// In Tauri, aggressively unregister any old service workers that might be causing 404s
|
||||
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js').catch(() => {});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
Before Width: | Height: | Size: 502 KiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.4 MiB |
@@ -77,7 +77,7 @@ checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3"
|
||||
|
||||
[[package]]
|
||||
name = "app"
|
||||
version = "0.2.0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"serde",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
@@ -1,20 +0,0 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
key.properties
|
||||
keystore.properties
|
||||
|
||||
/.tauri
|
||||
/tauri.settings.gradle
|
||||
@@ -1,6 +0,0 @@
|
||||
/src/main/**/generated
|
||||
/src/main/jniLibs/**/*.so
|
||||
/src/main/assets/tauri.conf.json
|
||||
/tauri.build.gradle.kts
|
||||
/proguard-tauri.pro
|
||||
/tauri.properties
|
||||
@@ -1,90 +0,0 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("rust")
|
||||
}
|
||||
|
||||
val tauriProperties = Properties().apply {
|
||||
val propFile = file("tauri.properties")
|
||||
if (propFile.exists()) {
|
||||
propFile.inputStream().use { load(it) }
|
||||
}
|
||||
}
|
||||
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystoreProperties = Properties()
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(keystorePropertiesFile.inputStream())
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
namespace = "coffee.dustin.dumpster"
|
||||
defaultConfig {
|
||||
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||||
applicationId = "coffee.dustin.dumpster"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||
}
|
||||
signingConfigs {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
create("release") {
|
||||
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||
storePassword = keystoreProperties["storePassword"] as String
|
||||
keyAlias = keystoreProperties["keyAlias"] as String
|
||||
keyPassword = keystoreProperties["keyPassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
getByName("debug") {
|
||||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||
isDebuggable = true
|
||||
isJniDebuggable = true
|
||||
isMinifyEnabled = false
|
||||
packaging { jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/x86/*.so")
|
||||
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
|
||||
}
|
||||
}
|
||||
getByName("release") {
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
*fileTree(".") { include("**/*.pro") }
|
||||
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||||
.toList().toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
rust {
|
||||
rootDirRel = "../../../"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.webkit:webkit:1.14.0")
|
||||
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||
}
|
||||
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- AndroidTV support -->
|
||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.app"
|
||||
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||
android:launchMode="singleTask"
|
||||
android:label="@string/main_activity_title"
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<!-- AndroidTV support -->
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,11 +0,0 @@
|
||||
package coffee.dustin.dumpster
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
||||
class MainActivity : TauriActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
@@ -1,170 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,10 +0,0 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. Forces dark mode since our CSS themes are always dark. -->
|
||||
<style name="Theme.app" parent="Theme.MaterialComponents.NoActionBar">
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<!-- Force light status bar icons (white) against our dark background -->
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:windowLightNavigationBar">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -1,4 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">"dumpsterChat"</string>
|
||||
<string name="main_activity_title">"dumpsterChat"</string>
|
||||
</resources>
|
||||
@@ -1,10 +0,0 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. Forces dark mode since our CSS themes are always dark. -->
|
||||
<style name="Theme.app" parent="Theme.MaterialComponents.NoActionBar">
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<!-- Force light status bar icons (white) against our dark background -->
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:windowLightNavigationBar">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="my_images" path="." />
|
||||
<cache-path name="my_cache_images" path="." />
|
||||
</paths>
|
||||
@@ -1,22 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:8.11.0")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("clean").configure {
|
||||
delete("build")
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("pluginsForCoolKids") {
|
||||
id = "rust"
|
||||
implementationClass = "RustPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(gradleApi())
|
||||
implementation("com.android.tools.build:gradle:8.11.0")
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import java.io.File
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
open class BuildTask : DefaultTask() {
|
||||
@Input
|
||||
var rootDirRel: String? = null
|
||||
@Input
|
||||
var target: String? = null
|
||||
@Input
|
||||
var release: Boolean? = null
|
||||
|
||||
@TaskAction
|
||||
fun assemble() {
|
||||
val executable = """npm""";
|
||||
try {
|
||||
runTauriCli(executable)
|
||||
} catch (e: Exception) {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
// Try different Windows-specific extensions
|
||||
val fallbacks = listOf(
|
||||
"$executable.exe",
|
||||
"$executable.cmd",
|
||||
"$executable.bat",
|
||||
)
|
||||
|
||||
var lastException: Exception = e
|
||||
for (fallback in fallbacks) {
|
||||
try {
|
||||
runTauriCli(fallback)
|
||||
return
|
||||
} catch (fallbackException: Exception) {
|
||||
lastException = fallbackException
|
||||
}
|
||||
}
|
||||
throw lastException
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun runTauriCli(executable: String) {
|
||||
val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
|
||||
val target = target ?: throw GradleException("target cannot be null")
|
||||
val release = release ?: throw GradleException("release cannot be null")
|
||||
val args = listOf("run", "--", "tauri", "android", "android-studio-script");
|
||||
|
||||
project.exec {
|
||||
workingDir(File(project.projectDir, rootDirRel))
|
||||
executable(executable)
|
||||
args(args)
|
||||
if (project.logger.isEnabled(LogLevel.DEBUG)) {
|
||||
args("-vv")
|
||||
} else if (project.logger.isEnabled(LogLevel.INFO)) {
|
||||
args("-v")
|
||||
}
|
||||
if (release) {
|
||||
args("--release")
|
||||
}
|
||||
args(listOf("--target", target))
|
||||
}.assertNormalExitValue()
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.get
|
||||
|
||||
const val TASK_GROUP = "rust"
|
||||
|
||||
open class Config {
|
||||
lateinit var rootDirRel: String
|
||||
}
|
||||
|
||||
open class RustPlugin : Plugin<Project> {
|
||||
private lateinit var config: Config
|
||||
|
||||
override fun apply(project: Project) = with(project) {
|
||||
config = extensions.create("rust", Config::class.java)
|
||||
|
||||
val defaultAbiList = listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64");
|
||||
val abiList = (findProperty("abiList") as? String)?.split(',') ?: defaultAbiList
|
||||
|
||||
val defaultArchList = listOf("arm64", "arm", "x86", "x86_64");
|
||||
val archList = (findProperty("archList") as? String)?.split(',') ?: defaultArchList
|
||||
|
||||
val targetsList = (findProperty("targetList") as? String)?.split(',') ?: listOf("aarch64", "armv7", "i686", "x86_64")
|
||||
|
||||
extensions.configure<ApplicationExtension> {
|
||||
@Suppress("UnstableApiUsage")
|
||||
flavorDimensions.add("abi")
|
||||
productFlavors {
|
||||
create("universal") {
|
||||
dimension = "abi"
|
||||
ndk {
|
||||
abiFilters += abiList
|
||||
}
|
||||
}
|
||||
defaultArchList.forEachIndexed { index, arch ->
|
||||
create(arch) {
|
||||
dimension = "abi"
|
||||
ndk {
|
||||
abiFilters.add(defaultAbiList[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
for (profile in listOf("debug", "release")) {
|
||||
val profileCapitalized = profile.replaceFirstChar { it.uppercase() }
|
||||
val buildTask = tasks.maybeCreate(
|
||||
"rustBuildUniversal$profileCapitalized",
|
||||
DefaultTask::class.java
|
||||
).apply {
|
||||
group = TASK_GROUP
|
||||
description = "Build dynamic library in $profile mode for all targets"
|
||||
}
|
||||
|
||||
tasks["mergeUniversal${profileCapitalized}JniLibFolders"].dependsOn(buildTask)
|
||||
|
||||
for (targetPair in targetsList.withIndex()) {
|
||||
val targetName = targetPair.value
|
||||
val targetArch = archList[targetPair.index]
|
||||
val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() }
|
||||
val targetBuildTask = project.tasks.maybeCreate(
|
||||
"rustBuild$targetArchCapitalized$profileCapitalized",
|
||||
BuildTask::class.java
|
||||
).apply {
|
||||
group = TASK_GROUP
|
||||
description = "Build dynamic library in $profile mode for $targetArch"
|
||||
rootDirRel = config.rootDirRel
|
||||
target = targetName
|
||||
release = profile == "release"
|
||||
}
|
||||
|
||||
buildTask.dependsOn(targetBuildTask)
|
||||
tasks["merge$targetArchCapitalized${profileCapitalized}JniLibFolders"].dependsOn(
|
||||
targetBuildTask
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonFinalResIds=false
|
||||
@@ -1,6 +0,0 @@
|
||||
#Tue May 10 19:22:52 CST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
@@ -1,185 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||