feat: bump version to 1.4.0 and allow users to request global topics

This commit is contained in:
2026-01-24 22:09:53 +08:00
parent 5dc6fe43d5
commit 4a91a0140a
10 changed files with 109 additions and 61 deletions

View File

@@ -4,7 +4,7 @@ This document provides instructions for AI agents working on the Alert Message C
## 🛠 Commands
### Development & Build
### Workspace Operations
- **Install**: `bun install`
- **Root Dev**: `bun run dev` (starts both server and web)
- **Root Build**: `bun run build`
@@ -25,6 +25,10 @@ This document provides instructions for AI agents working on the Alert Message C
- **Dev**: `bun run dev`
- **Build**: `bun run build`
### Testing
- No automated tests currently exist in the repository. If adding tests, use **Bun Test**.
- **Run Single Test**: `bun test path/to/file.test.ts`
---
## 📜 Code Style & Conventions
@@ -35,7 +39,7 @@ This document provides instructions for AI agents working on the Alert Message C
- **Naming**:
- Variables/Functions: `camelCase`
- Components/Classes/Interfaces: `PascalCase`
- Database Tables: `snake_case` (e.g., `topic_group_chats`)
- Database Tables/Columns: `snake_case` (e.g., `topic_group_chats`)
- URL Slugs: `kebab-case`
### 2. TypeScript & Type Safety
@@ -46,7 +50,7 @@ This document provides instructions for AI agents working on the Alert Message C
### 3. Backend (Hono + Drizzle)
- **Routing**: Group logic into sub-apps (e.g., `api.ts`, `auth.ts`, `webhook.ts`).
- **Database**: Use Drizzle ORM. Prefer relational queries where possible.
- **Database**: Use Drizzle ORM. Prefer relational queries where possible (`db.query.xxx.findMany`).
- **Validation**: Use `@hono/zod-validator` for request validation.
- **Logging**: Use the structured logger in `src/lib/logger.ts` (Pino).
- **Pattern**: `logger.error({ err, context }, "Message")`.
@@ -76,3 +80,4 @@ This document provides instructions for AI agents working on the Alert Message C
- **Biome First**: Always run `bun run check` before concluding a task.
- **Preserve Patterns**: Follow existing structure in `apps/server/src` and `apps/web/src`.
- **Minimalism**: Fix bugs minimally. Avoid large refactors unless requested.
- **Context**: Agent-specific context is located in `@docs/`. Refer to `docs/copilot-context.md` for additional instructions.

View File

@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
**CHANGELOG** | [简体中文](./CHANGELOG.zh-CN.md)
## [1.4.0] - 2026-01-23
### Added
- **Global Topics**: Introduced a new topic type that broadcasts alerts to all users automatically.
- **User Requests**: All users can now request a topic to be "Global" during creation.
- **Admin Control**: Admins can promote any topic to "Global" or create new global topics via the Admin Dashboard.
- **Automatic Distribution**: Alerts sent to Global Topics are delivered to every registered user without requiring individual subscriptions.
- **UI Indicators**: Added "Global" badges and specialized management actions in the Topics and Admin views.
## [1.3.3] - 2026-01-17
### Added

View File

@@ -7,6 +7,15 @@
**更新日志** | [English](./CHANGELOG.md)
## [1.4.0] - 2026-01-23
### 新增
- **全局话题 (Global Topics)**: 引入了全新的话题类型,可自动向所有用户广播告警。
- **用户申请**: 现在所有用户在创建话题时都可以选择申请将其设为“全局话题”。
- **管理员控制**: 管理员可以通过管理员后台将任何话题提升为“全局话题”,或直接创建新的全局话题。
- **自动分发**: 发送到全局话题的告警将投递给每一位已注册的用户,无需用户手动订阅。
- **UI 标识**: 在话题列表和管理员视图中增加了“全局”标识和专门的管理操作。
## [1.3.3] - 2026-01-17
### 新增

View File

@@ -1,6 +1,6 @@
{
"name": "@alertmessagecenter/server",
"version": "1.3.3",
"version": "1.4.0",
"scripts": {
"dev": "bun run --env-file .env --watch src/index.ts",
"start": "bun run src/index.ts",

View File

@@ -150,7 +150,7 @@ api.post("/topics", requireAuth, zValidator("json", topicSchema), async (c) => {
.insert(topics)
.values({
...body,
isGlobal: session.isAdmin ? (body.isGlobal ?? false) : false,
isGlobal: body.isGlobal ?? false,
status,
createdBy: session.id,
approvedBy: session.isAdmin || session.isTrusted ? session.id : null,

View File

@@ -1,6 +1,6 @@
{
"name": "@alertmessagecenter/web",
"version": "1.3.3",
"version": "1.4.0",
"type": "module",
"scripts": {
"dev": "bun run --env-file .env vite",

View File

@@ -534,42 +534,52 @@ export default function TopicsView() {
)}
</div>
{currentUser && (
<div className="mt-3 space-y-3">
<div className="bg-gray-50 p-2 rounded border border-gray-200">
<div className="flex justify-between items-center">
<span className="text-xs font-semibold text-gray-500 uppercase tracking-wider">
Your Personal Webhook
</span>
<button
type="button"
onClick={() =>
copyToClipboard(
getWebhookUrl(topic.slug),
topic.id,
)
}
className="text-indigo-600 hover:text-indigo-800 flex items-center text-xs font-medium"
>
{copiedId === topic.id ? (
<>
<Check className="w-3 h-3 mr-1" />
Copied!
</>
) : (
<>
<Copy className="w-3 h-3 mr-1" />
Copy URL
</>
)}
</button>
</div>
<div className="mt-1 text-xs font-mono text-gray-600 break-all select-all">
{getWebhookUrl(topic.slug)}
<div
className={`mt-3 ${topic.isGlobal ? "grid grid-cols-1 md:grid-cols-2 gap-4" : "space-y-3"}`}
>
<div className="bg-gray-50 p-3 rounded-lg border border-gray-200 shadow-sm flex flex-col justify-between">
<div>
<div className="flex justify-between items-center mb-1.5">
<span className="text-[10px] font-bold text-gray-500 uppercase tracking-widest">
Your Personal Webhook
</span>
<button
type="button"
onClick={() =>
copyToClipboard(
getWebhookUrl(topic.slug),
topic.id,
)
}
className="text-indigo-600 hover:text-indigo-800 flex items-center text-xs font-semibold bg-white px-2 py-0.5 rounded border border-gray-200 shadow-sm transition-all hover:shadow hover:translate-y-[-1px]"
>
{copiedId === topic.id ? (
<>
<Check className="w-3 h-3 mr-1" />
Copied
</>
) : (
<>
<Copy className="w-3 h-3 mr-1" />
Copy URL
</>
)}
</button>
</div>
<div className="text-[11px] font-mono text-gray-600 break-all select-all bg-white/60 p-1.5 rounded border border-gray-100/50 leading-relaxed">
{getWebhookUrl(topic.slug)}
</div>
</div>
{topic.isGlobal && (
<p className="mt-1.5 text-[10px] text-gray-400 italic">
* Requires your personal token to identify you
as the sender.
</p>
)}
</div>
{topic.isGlobal && (
<div className="bg-purple-50/50 p-3 rounded-lg border border-purple-100 shadow-sm relative overflow-hidden group">
<div className="bg-purple-50/50 p-3 rounded-lg border border-purple-100 shadow-sm relative overflow-hidden group flex flex-col justify-between">
<div className="absolute top-0 right-0 p-1 opacity-10 group-hover:opacity-20 transition-opacity">
<Globe className="w-12 h-12 text-purple-600" />
</div>
@@ -746,25 +756,26 @@ export default function TopicsView() {
}
/>
</div>
{currentUser?.isAdmin && (
<div className="flex items-center">
<input
id="is-global"
type="checkbox"
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
checked={formData.isGlobal || false}
onChange={(e) =>
setFormData({ ...formData, isGlobal: e.target.checked })
}
/>
<label
htmlFor="is-global"
className="ml-2 block text-sm text-gray-900 font-medium"
>
Global Topic (Bypass personal token authentication)
</label>
</div>
)}
<div className="flex items-center">
<input
id="is-global"
type="checkbox"
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
checked={formData.isGlobal || false}
onChange={(e) =>
setFormData({ ...formData, isGlobal: e.target.checked })
}
/>
<label
htmlFor="is-global"
className="ml-2 block text-sm text-gray-900 font-medium"
>
Global Topic
</label>
<p className="ml-2 text-xs text-gray-500">
(Broadcast to ALL users. Requires Admin approval)
</p>
</div>
<div>
<label
htmlFor="topic-description"

View File

@@ -1,7 +1,14 @@
# Project Context for GitHub Copilot (v1.3.3)
# Project Context for GitHub Copilot (v1.4.0)
This document provides technical context, architectural decisions, and code conventions for the **Alert Message Center** project. It is intended to help AI assistants understand the codebase.
## 0. AI/Agent Specific Instructions
> [!IMPORTANT]
> **AI Agents MUST read [AGENTS.md](../AGENTS.md) first.** It contains critical information about:
> - Build/lint/test commands.
> - Required code style (tabs, double quotes, naming conventions).
> - Hard rules (NO `any`, Biome checks).
## 1. Project Overview
**Alert Message Center** (formerly Alert Manager) is a centralized alert dispatching system.
@@ -41,6 +48,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
- `name`: Display name (e.g., "Payment Service Errors").
- `slug`: URL-safe identifier (e.g., `payment-errors`). Used in webhook URLs.
- `description`: Optional text.
- `isGlobal`: Boolean flag. If true, alerts are sent to all users automatically.
- `status`: `pending`, `approved`, or `rejected`.
- `createdBy`: Foreign Key -> `users.id`.
- `approvedBy`: Foreign Key -> `users.id`.
@@ -115,7 +123,11 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
- **Topic-based**: `POST /api/webhook/:token/topic/:slug`
- **Direct (Inbox)**: `POST /api/webhook/:token/dm`
2. **Lookup**:
- For Topic-based: Find `Topic` by `slug` and fetch all `subscriptions`.
- For Topic-based: Find `Topic` by `slug`.
- **Recipients**:
- If `isGlobal` is true: Fetch all active users from DB.
- If not global: Fetch all `subscriptions` for that topic.
- Always fetch all bound `topic_group_chats`.
- For Direct: Identify the user via `token`.
3. **Dispatch**:
- Call `FeishuClient.sendMessage` for each recipient.
@@ -171,7 +183,7 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
- `GET /api/topics/my-requests`: List user's own topic requests.
- `GET /api/topics/requests`: List pending topic requests (Admin only).
- `GET /api/topics/all`: List all topics regardless of status (Admin only).
- `POST /api/topics`: Create a topic (Admin creates approved, User creates pending).
- `POST /api/topics`: Create a topic (Admin/Trusted creates approved, User creates pending; Supports `isGlobal`).
- `POST /api/topics/:id/approve`: Approve a topic request (Admin only).
- `POST /api/topics/:id/reject`: Reject a topic request (Admin only).
- `DELETE /api/topics/:id`: Delete a topic (Admin only).
@@ -250,5 +262,6 @@ The database schema is defined in `apps/server/src/db/schema.ts`.
- **[README.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.md)**: Main project documentation (English version).
- **[README.zh-CN.md](file:///Users/lilithgames/Workspace/play/alert-message-center/README.zh-CN.md)**: Simplified Chinese version of the documentation.
- **[AGENTS.md](file:///Users/lilithgames/Workspace/play/alert-message-center/AGENTS.md)**: Specialized instructions and conventions for AI agents.
- **[CHANGELOG.md](file:///Users/lilithgames/Workspace/play/alert-message-center/CHANGELOG.md)**: Record of version changes.
- **[todo.md](file:///Users/lilithgames/Workspace/play/alert-message-center/todo.md)**: Task tracking.

View File

@@ -1,6 +1,6 @@
{
"name": "alertmessagecenter",
"version": "1.1.1",
"version": "1.4.0",
"workspaces": [
"apps/*"
],

View File

@@ -16,6 +16,7 @@
## Phase 2: Enhancements
- [x] **Authentication**: Feishu SSO integration and role-based access control.
- [x] **Global Monitoring Dashboard**: Real-time System Load metrics (Grafana-style).
- [x] **Global Topics**: Support for broadcasting alerts to all users automatically.
- [ ] **Message Preview**: Preview Feishu card JSON in the UI.
- [x] **History/Logs**: Basic tracking for sent alerts (Alert Tasks/Logs).
- [x] **Admin Topic Management**: Approve, reject, and delete topics (with audit trail).