mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 07:06:36 +08:00
528240026d
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯 - .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化) - 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package message_gateway
|
|
|
|
import (
|
|
"Wavelet/core/contracts"
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// AdminLogin is the metadata definition for the admin login event.
|
|
var AdminLogin = EventMetadata{
|
|
Key: "admin_login",
|
|
Name: "管理员登录",
|
|
DefaultTemplate: NotificationMessage{
|
|
Title: "管理员登录提醒",
|
|
Content: "管理员 {{user.username}} 于 {{time}} 从 IP {{ip}} 登录系统。",
|
|
Level: "INFO",
|
|
},
|
|
Description: "当管理员成功登录系统时触发此通知",
|
|
}
|
|
|
|
// HandleAdminLoggedIn 处理管理员登录事件并触发通知
|
|
func HandleAdminLoggedIn(ctx context.Context, event contracts.AdminLoggedIn) {
|
|
if event.User == nil {
|
|
return
|
|
}
|
|
|
|
body := map[string]any{
|
|
"user": event.User,
|
|
"ip": event.IP,
|
|
"time": time.Now().Format("2006-01-02 15:04:05"),
|
|
}
|
|
DefaultTrigger.Trigger(ctx, AdminLogin, body)
|
|
}
|
|
|
|
// RegisterCustomEvents registers default domain push notification events.
|
|
func RegisterCustomEvents() {
|
|
RegisterBuiltInEvent(AdminLogin)
|
|
}
|