mirror of
https://github.com/vernu/textbee.git
synced 2026-04-19 06:22:10 -04:00
feat(api): save default sms sending delay config
This commit is contained in:
@@ -468,6 +468,13 @@ export class HeartbeatInputDTO {
|
||||
})
|
||||
receiveSMSEnabled?: boolean
|
||||
|
||||
@ApiProperty({
|
||||
type: Number,
|
||||
required: false,
|
||||
description: 'SMS send delay in seconds (0-3600), used by device queue',
|
||||
})
|
||||
smsSendDelaySeconds?: number
|
||||
|
||||
@ApiProperty({ type: SimInfoCollectionDTO, required: false })
|
||||
simInfo?: SimInfoCollectionDTO
|
||||
}
|
||||
|
||||
@@ -1089,6 +1089,15 @@ const updatedSms = await this.smsModel.findByIdAndUpdate(
|
||||
updateData.receiveSMSEnabled = input.receiveSMSEnabled
|
||||
}
|
||||
|
||||
// Update smsSendDelaySeconds if provided (clamp 0-3600)
|
||||
if (input.smsSendDelaySeconds !== undefined) {
|
||||
const clamped = Math.min(
|
||||
3600,
|
||||
Math.max(0, Math.floor(Number(input.smsSendDelaySeconds))),
|
||||
)
|
||||
updateData.smsSendDelaySeconds = clamped
|
||||
}
|
||||
|
||||
// Update batteryInfo if provided
|
||||
if (input.batteryPercentage !== undefined || input.isCharging !== undefined) {
|
||||
if (input.batteryPercentage !== undefined) {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { User } from '../../users/schemas/user.schema'
|
||||
|
||||
export type DeviceDocument = Device & Document
|
||||
|
||||
/** Default delay between SMS sends (seconds). 5s helps avoid carrier/device throttling. */
|
||||
export const DEFAULT_SMS_SEND_DELAY_SECONDS = 5
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class Device {
|
||||
_id?: Types.ObjectId
|
||||
@@ -62,6 +65,9 @@ export class Device {
|
||||
@Prop({ type: Boolean, default: false })
|
||||
receiveSMSEnabled: boolean
|
||||
|
||||
@Prop({ type: Number, default: DEFAULT_SMS_SEND_DELAY_SECONDS })
|
||||
smsSendDelaySeconds: number
|
||||
|
||||
@Prop({ type: Date })
|
||||
lastHeartbeat: Date
|
||||
|
||||
|
||||
Reference in New Issue
Block a user