@@ -38,6 +38,7 @@ export const generateDefaultConfig: () => IConfig = () => ({
|
||||
key: '',
|
||||
serverUrl: 'https://api.day.app',
|
||||
enableComment: true,
|
||||
enableThrottleGuard: false,
|
||||
},
|
||||
friendLinkOptions: { allowApply: true },
|
||||
backupOptions: {
|
||||
|
||||
@@ -295,6 +295,13 @@ export class BarkOptionsDto {
|
||||
@IsBoolean()
|
||||
@JSONSchemaToggleField('开启评论通知')
|
||||
enableComment: boolean
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@JSONSchemaToggleField('开启请求被限流时通知', {
|
||||
description: '当请求被限流会通知,或许可以一定程度上预警被攻击',
|
||||
})
|
||||
enableThrottleGuard: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,8 +31,12 @@ export class BarkPushService {
|
||||
) {}
|
||||
|
||||
async push(options: BarkPushOptions) {
|
||||
const { key, serverUrl = 'https://day.app' } =
|
||||
await this.config.get('barkOptions')
|
||||
const {
|
||||
key,
|
||||
serverUrl = 'https://day.app',
|
||||
enableThrottleGuard,
|
||||
} = await this.config.get('barkOptions')
|
||||
if (!enableThrottleGuard) return
|
||||
const { title: siteTitle } = await this.config.get('seo')
|
||||
if (!key) {
|
||||
throw new Error('Bark key is not configured')
|
||||
|
||||
Reference in New Issue
Block a user