Skip to content

Commit 99ad8a7

Browse files
committed
fix: correct 6 doc inaccuracies and wire MARCHAT_SESSION_SECRET to web admin
- README: Database Schema lists all 6 tables (was missing message_reactions, user_channels, read_receipts) - README: Plugin Commands heading no longer claims all plugin commands are admin-only - ARCHITECTURE.md: schema DDL notes SQLite dialect, adds 3 missing table definitions - TESTING.md: reconcile stale coverage numbers in Areas for Future Testing - server/admin_web.go: use cfg.SessionSecret (from MARCHAT_SESSION_SECRET env) when set instead of always generating a random secret
1 parent 8d419ba commit 99ad8a7

4 files changed

Lines changed: 48 additions & 9 deletions

File tree

ARCHITECTURE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ See [PROTOCOL.md](PROTOCOL.md) for the full message format specification.
277277

278278
## Database Schema
279279

280+
DDL below uses the **SQLite** dialect for readability. PostgreSQL and MySQL variants differ in type names (`BIGSERIAL`/`BIGINT AUTO_INCREMENT` for IDs, `VARCHAR(191)` for indexed text on MySQL, `LONGTEXT`/`LONGBLOB` for large fields) and are generated by `CreateSchema` in `server/handlers.go`.
281+
280282
### Tables
281283

282284
#### `messages`
@@ -317,6 +319,38 @@ CREATE TABLE ban_history (
317319
);
318320
```
319321

322+
#### `message_reactions`
323+
```sql
324+
CREATE TABLE message_reactions (
325+
id INTEGER PRIMARY KEY AUTOINCREMENT,
326+
message_id INTEGER NOT NULL,
327+
username TEXT NOT NULL,
328+
emoji TEXT NOT NULL,
329+
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
330+
UNIQUE(message_id, username, emoji)
331+
);
332+
```
333+
334+
#### `user_channels`
335+
```sql
336+
CREATE TABLE user_channels (
337+
username TEXT NOT NULL,
338+
channel TEXT NOT NULL,
339+
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
340+
PRIMARY KEY (username)
341+
);
342+
```
343+
344+
#### `read_receipts`
345+
```sql
346+
CREATE TABLE read_receipts (
347+
username TEXT NOT NULL,
348+
message_id INTEGER NOT NULL,
349+
read_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
350+
PRIMARY KEY (username, message_id)
351+
);
352+
```
353+
320354
### Key Features
321355

322356
- **Backend Selection**: `MARCHAT_DB_PATH` chooses SQLite/PostgreSQL/MySQL at runtime

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ Runs a guided wizard **only when** `MARCHAT_ADMIN_KEY` or `MARCHAT_USERS` is not
128128

129129
## Database Schema
130130

131-
Key tables for message tracking and moderation:
132-
- **messages**: Core message storage with `message_id`
133-
- **user_message_state**: Per-user message history state
131+
Tables created by the server (dialect-aware DDL for SQLite, PostgreSQL, and MySQL):
132+
- **messages**: Core message storage with `message_id`, encryption fields, edit/delete/pin flags
133+
- **user_message_state**: Per-user message history state and last-seen timestamp
134134
- **ban_history**: Ban/unban event tracking for history gaps
135+
- **message_reactions**: Durable emoji reactions (unique per message + user + emoji)
136+
- **user_channels**: Last channel per user, persisted across reconnects
137+
- **read_receipts**: Per-user read receipt state tracking
135138

136139
## Installation
137140

@@ -331,9 +334,9 @@ Run **`./marchat-client -doctor`** or **`./marchat-server -doctor`** for a text
331334
>
332335
> **Notifications**: See [NOTIFICATIONS.md](NOTIFICATIONS.md) for full notification system documentation including desktop notifications, quiet hours, and focus mode.
333336
334-
### Plugin Commands (Admin Only)
337+
### Plugin Commands
335338

336-
Text commands and hotkeys for plugin management. See [Plugin Management hotkeys](#plugin-management-admin) for keyboard shortcuts.
339+
Plugin **management** (install, uninstall, enable, disable) is admin-only. Plugin **chat commands** (e.g. `:echo`, `:weather`) are available to all users unless the plugin manifest sets `AdminOnly: true`. See [Plugin Management hotkeys](#plugin-management-admin) for keyboard shortcuts.
337340

338341
| Command | Description | Hotkey |
339342
|---------|-------------|--------|

TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ Statement percentages below are from the merged profile (`go tool cover -func=co
245245
| `client/main.go` | 6.7% | client | Client main application |
246246

247247
### Areas for Future Testing
248-
- **Server Package**: Advanced WebSocket handling, complex message routing scenarios (current: 35.4%)
249-
- **Client Package**: WebSocket communication, full TUI integration (current: 23.1%)
248+
- **Server Package**: Advanced WebSocket handling, complex message routing scenarios (current: 36.1%)
249+
- **Client Package**: WebSocket communication, full TUI integration (current: 23.0%)
250250
- **Plugin Host**: Broader command/response paths and failure modes beyond the minimal IPC test plugin (current: 63.2%)
251251
- **Plugin Manager**: Store download, checksum, and install edge cases (current: 32.1%)
252252
- **Server Main**: Full `main` execution, HTTP/TLS serving, admin panel integration (current: 13.7% statement coverage for `cmd/server/main.go`)

server/admin_web.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,10 @@ func NewWebAdminServer(hub *Hub, db *sql.DB, cfg *config.Config) *WebAdminServer
357357
loginAttempts: make(map[string]*loginAttempt),
358358
}
359359

360-
// Generate session secret
361-
if err := server.generateSessionSecret(); err != nil {
360+
// Use configured session secret when available, otherwise generate a random one
361+
if cfg.SessionSecret != "" {
362+
server.sessionSecret = []byte(cfg.SessionSecret)
363+
} else if err := server.generateSessionSecret(); err != nil {
362364
log.Printf("Warning: Failed to generate session secret: %v", err)
363365
}
364366

0 commit comments

Comments
 (0)