feature/cleaner #1
18 changed files with 871 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Aero Mail — Установка
|
||||
# Aero Mail — Установка
|
||||
|
||||
## Требования
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,16 @@ export default defineConfig({
|
|||
'@shared': resolve('src/shared'),
|
||||
'@main': resolve('src/main')
|
||||
}
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
// retention-worker — отдельная точка входа: запускается через worker_threads
|
||||
// как самостоятельный .js-файл, а не импортируется из index.ts
|
||||
input: {
|
||||
index: resolve('src/main/index.ts'),
|
||||
'workers/retention-worker': resolve('src/main/workers/retention-worker.ts')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
preload: {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,18 @@ import { join, basename } from 'node:path'
|
|||
import { statSync, mkdirSync, copyFileSync, writeFileSync, readdirSync, unlinkSync, existsSync } from 'node:fs'
|
||||
import { homedir } from 'node:os'
|
||||
import { AccountManager } from './services/account-manager'
|
||||
import { RetentionService } from './services/retention-service'
|
||||
import { registerAccountHandlers } from './ipc/accounts.handler'
|
||||
import { registerFolderHandlers } from './ipc/folders.handler'
|
||||
import { registerMessageHandlers } from './ipc/messages.handler'
|
||||
import { registerCalendarHandlers } from './ipc/calendar.handler'
|
||||
import { registerUpdaterHandlers } from './ipc/updater.handler'
|
||||
import { registerRetentionHandlers } from './ipc/retention.handler'
|
||||
import { updater } from './services/updater'
|
||||
import type { ComposeSession } from '@shared/types/message'
|
||||
|
||||
const accountManager = new AccountManager()
|
||||
const retentionService = new RetentionService(accountManager)
|
||||
|
||||
// ── Compose windows ───────────────────────────────────────
|
||||
// webContentsId → session, заполняется до loadURL, читается окном при монтировании
|
||||
|
|
@ -95,6 +98,7 @@ function createWindow(): BrowserWindow {
|
|||
})
|
||||
|
||||
accountManager.setMainWindow(mainWindow)
|
||||
retentionService.setMainWindow(mainWindow)
|
||||
|
||||
// Разрешаем Web Notifications API из renderer
|
||||
mainWindow.webContents.session.setPermissionRequestHandler((_wc, permission, callback) => {
|
||||
|
|
@ -195,11 +199,12 @@ app.whenReady().then(async () => {
|
|||
await accountManager.initialize()
|
||||
|
||||
// Register all IPC handlers
|
||||
registerAccountHandlers(accountManager)
|
||||
registerAccountHandlers(accountManager, retentionService)
|
||||
registerFolderHandlers(accountManager)
|
||||
registerMessageHandlers(accountManager)
|
||||
registerCalendarHandlers(accountManager)
|
||||
registerUpdaterHandlers()
|
||||
registerRetentionHandlers(retentionService)
|
||||
|
||||
createWindow()
|
||||
|
||||
|
|
@ -219,3 +224,7 @@ app.on('window-all-closed', () => {
|
|||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('before-quit', () => {
|
||||
retentionService.dispose()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { registerHandler } from './registry'
|
||||
import type { AccountManager } from '../services/account-manager'
|
||||
import type { RetentionService } from '../services/retention-service'
|
||||
import { safeStorage } from 'electron'
|
||||
|
||||
export function registerAccountHandlers(manager: AccountManager): void {
|
||||
export function registerAccountHandlers(manager: AccountManager, retentionService: RetentionService): void {
|
||||
registerHandler('app:isEncryptionAvailable', async () => {
|
||||
return safeStorage.isEncryptionAvailable()
|
||||
})
|
||||
|
|
@ -16,6 +17,7 @@ export function registerAccountHandlers(manager: AccountManager): void {
|
|||
|
||||
registerHandler('accounts:remove', async ({ accountId }) => {
|
||||
await manager.removeAccount(accountId)
|
||||
retentionService.removeRulesForAccount(accountId)
|
||||
})
|
||||
|
||||
registerHandler('accounts:test', async (config) => {
|
||||
|
|
|
|||
37
src/main/ipc/retention.handler.ts
Normal file
37
src/main/ipc/retention.handler.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { registerHandler } from './registry'
|
||||
import type { RetentionService } from '../services/retention-service'
|
||||
|
||||
function assertId(value: unknown, name: string): asserts value is string {
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
throw new Error(`Invalid IPC argument: ${name} must be a non-empty string`)
|
||||
}
|
||||
}
|
||||
|
||||
export function registerRetentionHandlers(retentionService: RetentionService): void {
|
||||
registerHandler('retention:list', async ({ accountId }) => {
|
||||
assertId(accountId, 'accountId')
|
||||
return retentionService.listRules(accountId)
|
||||
})
|
||||
|
||||
registerHandler('retention:set', async (rule) => {
|
||||
assertId(rule.accountId, 'accountId')
|
||||
assertId(rule.folderId, 'folderId')
|
||||
if (!Number.isInteger(rule.maxMessages) || rule.maxMessages < 1) {
|
||||
throw new Error('Invalid IPC argument: maxMessages must be a positive integer')
|
||||
}
|
||||
retentionService.setRule(rule)
|
||||
})
|
||||
|
||||
registerHandler('retention:remove', async ({ accountId, folderId }) => {
|
||||
assertId(accountId, 'accountId')
|
||||
assertId(folderId, 'folderId')
|
||||
retentionService.removeRule(accountId, folderId)
|
||||
})
|
||||
|
||||
registerHandler('retention:setCheckInterval', async ({ minutes }) => {
|
||||
if (typeof minutes !== 'number' || minutes < 0) {
|
||||
throw new Error('Invalid IPC argument: minutes must be a non-negative number')
|
||||
}
|
||||
retentionService.setCheckInterval(minutes)
|
||||
})
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import type { MessageBody, MessageFlags, MessageEnvelope, Address, ComposeData,
|
|||
import { SpecialFolderRole } from '@shared/types/folder'
|
||||
import type { Folder } from '@shared/types/folder'
|
||||
import type { AccountConfig, ImapCredentials } from '@shared/types/account'
|
||||
import type { FolderRetentionRule, RetentionCleanupResult } from '@shared/types/retention'
|
||||
import { sanitizeHtml } from '../lib/html-sanitizer'
|
||||
|
||||
// imapflow MailboxObject type
|
||||
|
|
@ -305,6 +306,64 @@ export class ImapProvider implements IEmailProvider {
|
|||
}
|
||||
}
|
||||
|
||||
async enforceRetention(rules: FolderRetentionRule[]): Promise<RetentionCleanupResult[]> {
|
||||
if (rules.length === 0) return []
|
||||
const tree = await this.client.listTree() as { folders?: ImapMailbox[] }
|
||||
const folders = this.convertMailboxArray(tree.folders ?? [])
|
||||
const results: RetentionCleanupResult[] = []
|
||||
await this.enforceRetentionTree(folders, rules, null, results)
|
||||
return results
|
||||
}
|
||||
|
||||
// inheritedLimit — лимит, унаследованный от ближайшего предка с recursive: true (null — нет ограничения)
|
||||
private async enforceRetentionTree(
|
||||
folders: Folder[],
|
||||
rules: FolderRetentionRule[],
|
||||
inheritedLimit: number | null,
|
||||
results: RetentionCleanupResult[]
|
||||
): Promise<void> {
|
||||
for (const folder of folders) {
|
||||
const ownRule = rules.find((r) => r.folderId === folder.id)
|
||||
const effectiveLimit = ownRule ? ownRule.maxMessages : inheritedLimit
|
||||
|
||||
if (effectiveLimit !== null) {
|
||||
try {
|
||||
const deletedCount = await this.trimFolder(folder.id, effectiveLimit)
|
||||
if (deletedCount > 0) results.push({ folderId: folder.id, deletedCount })
|
||||
} catch (err) {
|
||||
console.warn(`[IMAP:retention] folder error ${folder.id}:`, (err as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
const childInheritedLimit = ownRule ? (ownRule.recursive ? ownRule.maxMessages : null) : inheritedLimit
|
||||
if (folder.children.length > 0) {
|
||||
await this.enforceRetentionTree(folder.children, rules, childInheritedLimit, results)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Удаляет самые старые письма сверх maxMessages. Сортировка по sequence number —
|
||||
// тот же порядок "старое → новое", что используется в listMessages.
|
||||
private async trimFolder(folderId: string, maxMessages: number): Promise<number> {
|
||||
const lock = await this.client.getMailboxLock(folderId)
|
||||
try {
|
||||
const total = (this.client.mailbox as { exists?: number })?.exists ?? 0
|
||||
const excess = total - maxMessages
|
||||
if (excess <= 0) return 0
|
||||
|
||||
const uidsToDelete: number[] = []
|
||||
for await (const msg of this.client.fetch(`1:${excess}`, { uid: true })) {
|
||||
uidsToDelete.push((msg as { uid: number }).uid)
|
||||
}
|
||||
if (uidsToDelete.length === 0) return 0
|
||||
|
||||
await this.client.messageDelete(uidsToDelete.join(','), { uid: true })
|
||||
return uidsToDelete.length
|
||||
} finally {
|
||||
lock.release()
|
||||
}
|
||||
}
|
||||
|
||||
async sendMessage(compose: ComposeData): Promise<void> {
|
||||
const creds = this.config.credentials as ImapCredentials
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { AccountType } from '@shared/types/account'
|
|||
import type { IEmailProvider, FolderListResult, MessageListResult } from '@shared/types/provider'
|
||||
import type { MessageBody, MessageFlags, MessageEnvelope, ComposeData } from '@shared/types/message'
|
||||
import type { CalendarInfo, CalendarEvent } from '@shared/types/calendar'
|
||||
import type { FolderRetentionRule, RetentionCleanupResult } from '@shared/types/retention'
|
||||
import { ImapProvider } from '../providers/imap.provider'
|
||||
import { CalDavProvider } from '../providers/caldav.provider'
|
||||
import { CredentialStore } from './credential-store'
|
||||
|
|
@ -216,6 +217,16 @@ export class AccountManager {
|
|||
)
|
||||
}
|
||||
|
||||
getConnectedAccountIds(): string[] {
|
||||
return [...this.providers.keys()]
|
||||
}
|
||||
|
||||
async enforceRetention(accountId: string, rules: FolderRetentionRule[]): Promise<RetentionCleanupResult[]> {
|
||||
return this.withAutoReconnect(accountId, () =>
|
||||
this.getProvider(accountId).enforceRetention(rules)
|
||||
)
|
||||
}
|
||||
|
||||
// ── Calendar ────────────────────────────────────────────
|
||||
|
||||
async listCalendars(accountId: string): Promise<CalendarInfo[]> {
|
||||
|
|
|
|||
79
src/main/services/retention-service.ts
Normal file
79
src/main/services/retention-service.ts
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { Worker } from 'node:worker_threads'
|
||||
import { join } from 'node:path'
|
||||
import type { BrowserWindow } from 'electron'
|
||||
import type { FolderRetentionRule } from '@shared/types/retention'
|
||||
import type { AccountManager } from './account-manager'
|
||||
import { RetentionStore } from './retention-store'
|
||||
|
||||
export class RetentionService {
|
||||
private worker: Worker
|
||||
private store = new RetentionStore()
|
||||
private mainWindow: BrowserWindow | null = null
|
||||
private checking = false
|
||||
|
||||
constructor(private accountManager: AccountManager) {
|
||||
this.worker = new Worker(join(__dirname, 'workers/retention-worker.js'))
|
||||
this.worker.on('message', (msg: { type: string }) => {
|
||||
if (msg.type === 'tick') {
|
||||
this.runCheck().catch((err) => {
|
||||
console.error('[RetentionService] check failed:', err)
|
||||
})
|
||||
}
|
||||
})
|
||||
this.worker.on('error', (err) => {
|
||||
console.error('[RetentionService] worker error:', err)
|
||||
})
|
||||
}
|
||||
|
||||
setMainWindow(win: BrowserWindow): void {
|
||||
this.mainWindow = win
|
||||
}
|
||||
|
||||
setCheckInterval(minutes: number): void {
|
||||
this.worker.postMessage({ type: 'setInterval', intervalMinutes: minutes })
|
||||
}
|
||||
|
||||
listRules(accountId: string): FolderRetentionRule[] {
|
||||
return this.store.getForAccount(accountId)
|
||||
}
|
||||
|
||||
setRule(rule: FolderRetentionRule): void {
|
||||
this.store.set(rule)
|
||||
}
|
||||
|
||||
removeRule(accountId: string, folderId: string): void {
|
||||
this.store.remove(accountId, folderId)
|
||||
}
|
||||
|
||||
removeRulesForAccount(accountId: string): void {
|
||||
this.store.removeForAccount(accountId)
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.worker.terminate().catch(() => {})
|
||||
}
|
||||
|
||||
private async runCheck(): Promise<void> {
|
||||
// Тики могут прийти чаще, чем успевает отработать предыдущая проверка (медленная сеть) — пропускаем внахлёст
|
||||
if (this.checking) return
|
||||
this.checking = true
|
||||
try {
|
||||
for (const accountId of this.accountManager.getConnectedAccountIds()) {
|
||||
const rules = this.store.getForAccount(accountId)
|
||||
if (rules.length === 0) continue
|
||||
|
||||
try {
|
||||
const results = await this.accountManager.enforceRetention(accountId, rules)
|
||||
const cleaned = results.filter((r) => r.deletedCount > 0)
|
||||
if (cleaned.length > 0 && this.mainWindow && !this.mainWindow.isDestroyed()) {
|
||||
this.mainWindow.webContents.send('retention:cleaned', { accountId, results: cleaned })
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`[RetentionService] enforceRetention failed for ${accountId}:`, (err as Error).message)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.checking = false
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/services/retention-store.ts
Normal file
46
src/main/services/retention-store.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import Store from 'electron-store'
|
||||
import type { FolderRetentionRule } from '@shared/types/retention'
|
||||
|
||||
interface RetentionStoreSchema {
|
||||
rules: FolderRetentionRule[]
|
||||
}
|
||||
|
||||
export class RetentionStore {
|
||||
private store: Store<RetentionStoreSchema>
|
||||
|
||||
constructor() {
|
||||
this.store = new Store<RetentionStoreSchema>({
|
||||
name: 'retention-rules',
|
||||
defaults: { rules: [] }
|
||||
})
|
||||
}
|
||||
|
||||
getAll(): FolderRetentionRule[] {
|
||||
return this.store.get('rules', [])
|
||||
}
|
||||
|
||||
getForAccount(accountId: string): FolderRetentionRule[] {
|
||||
return this.getAll().filter((r) => r.accountId === accountId)
|
||||
}
|
||||
|
||||
set(rule: FolderRetentionRule): void {
|
||||
const rules = this.getAll()
|
||||
const idx = rules.findIndex((r) => r.accountId === rule.accountId && r.folderId === rule.folderId)
|
||||
if (idx === -1) {
|
||||
rules.push(rule)
|
||||
} else {
|
||||
rules[idx] = rule
|
||||
}
|
||||
this.store.set('rules', rules)
|
||||
}
|
||||
|
||||
remove(accountId: string, folderId: string): void {
|
||||
const rules = this.getAll().filter((r) => !(r.accountId === accountId && r.folderId === folderId))
|
||||
this.store.set('rules', rules)
|
||||
}
|
||||
|
||||
removeForAccount(accountId: string): void {
|
||||
const rules = this.getAll().filter((r) => r.accountId !== accountId)
|
||||
this.store.set('rules', rules)
|
||||
}
|
||||
}
|
||||
28
src/main/workers/retention-worker.ts
Normal file
28
src/main/workers/retention-worker.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { parentPort } from 'node:worker_threads'
|
||||
|
||||
// Отдельный поток: только тикающий таймер, никакой работы с IMAP здесь не делаем —
|
||||
// imapflow-соединения и расшифрованные credentials живут в main-потоке (AccountManager),
|
||||
// worker_threads не имеют доступа к Electron API (safeStorage и т.п.), поэтому реальная
|
||||
// очистка выполняется в RetentionService по сигналу тика.
|
||||
type WorkerMessage =
|
||||
| { type: 'setInterval'; intervalMinutes: number }
|
||||
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
function applyInterval(intervalMinutes: number): void {
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
if (intervalMinutes > 0) {
|
||||
timer = setInterval(() => {
|
||||
parentPort?.postMessage({ type: 'tick' })
|
||||
}, intervalMinutes * 60_000)
|
||||
}
|
||||
}
|
||||
|
||||
parentPort?.on('message', (msg: WorkerMessage) => {
|
||||
if (msg.type === 'setInterval') {
|
||||
applyInterval(msg.intervalMinutes)
|
||||
}
|
||||
})
|
||||
|
|
@ -2,12 +2,16 @@
|
|||
import { onMounted, onUnmounted, watch } from 'vue'
|
||||
import { useAccountsStore } from './stores/accounts.store'
|
||||
import { useSettingsStore } from './stores/settings.store'
|
||||
import { useFoldersStore } from './stores/folders.store'
|
||||
import { useMessagesStore } from './stores/messages.store'
|
||||
import { useIpc } from './composables/useIpc'
|
||||
import UpdateBanner from './components/UpdateBanner.vue'
|
||||
|
||||
const accountsStore = useAccountsStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
const { invoke } = useIpc()
|
||||
const foldersStore = useFoldersStore()
|
||||
const messagesStore = useMessagesStore()
|
||||
const { invoke, on } = useIpc()
|
||||
|
||||
onMounted(() => {
|
||||
accountsStore.loadAccounts()
|
||||
|
|
@ -35,6 +39,30 @@ function restartPollTimer(): void {
|
|||
watch(() => settingsStore.autoCheckInterval, restartPollTimer)
|
||||
onMounted(restartPollTimer)
|
||||
onUnmounted(() => { if (pollTimer) clearInterval(pollTimer) })
|
||||
|
||||
// ── Лимит хранения писем: интервал проверки — тот же, что для проверки почты ──
|
||||
// Тикает в отдельном worker-потоке main-процесса (RetentionService)
|
||||
function pushRetentionInterval(): void {
|
||||
invoke('retention:setCheckInterval', { minutes: settingsStore.autoCheckInterval }).catch(() => {})
|
||||
}
|
||||
|
||||
watch(() => settingsStore.autoCheckInterval, pushRetentionInterval)
|
||||
onMounted(pushRetentionInterval)
|
||||
|
||||
let unsubRetentionCleaned: (() => void) | null = null
|
||||
|
||||
onMounted(() => {
|
||||
unsubRetentionCleaned = on('retention:cleaned', ({ accountId, results }) => {
|
||||
foldersStore.refreshUnreadCounts(accountId)
|
||||
if (accountsStore.activeAccountId === accountId
|
||||
&& foldersStore.activeFolderId
|
||||
&& results.some((r) => r.folderId === foldersStore.activeFolderId)) {
|
||||
messagesStore.loadMessages(accountId, foldersStore.activeFolderId, 0)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => { unsubRetentionCleaned?.() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ const props = defineProps<{
|
|||
folderId: string
|
||||
folderName: string
|
||||
isMuted: boolean
|
||||
hasRetentionRule: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
|
@ -15,6 +16,8 @@ const emit = defineEmits<{
|
|||
mute: [durationMs: number | null]
|
||||
unmute: []
|
||||
markAllRead: []
|
||||
editRetention: []
|
||||
removeRetention: []
|
||||
}>()
|
||||
|
||||
const menuEl = ref<HTMLElement | null>(null)
|
||||
|
|
@ -42,6 +45,14 @@ function handleMarkAllRead(): void {
|
|||
emit('markAllRead')
|
||||
}
|
||||
|
||||
function handleEditRetention(): void {
|
||||
emit('editRetention')
|
||||
}
|
||||
|
||||
function handleRemoveRetention(): void {
|
||||
emit('removeRetention')
|
||||
}
|
||||
|
||||
function onMouseDown(e: MouseEvent): void {
|
||||
if (menuEl.value && !menuEl.value.contains(e.target as Node)) {
|
||||
emit('close')
|
||||
|
|
@ -111,6 +122,15 @@ onUnmounted(() => {
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="menu-divider" />
|
||||
|
||||
<button class="menu-item" @click="handleEditRetention">
|
||||
{{ hasRetentionRule ? 'Изменить лимит сообщений…' : 'Ограничить количество сообщений…' }}
|
||||
</button>
|
||||
<button v-if="hasRetentionRule" class="menu-item" @click="handleRemoveRetention">
|
||||
Убрать ограничение
|
||||
</button>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import { useFoldersStore } from '../../stores/folders.store'
|
|||
import { useAccountsStore } from '../../stores/accounts.store'
|
||||
import { useNotificationsStore } from '../../stores/notifications.store'
|
||||
import { useMessagesStore } from '../../stores/messages.store'
|
||||
import { useRetentionStore } from '../../stores/retention.store'
|
||||
import AppIcon from '../AppIcon.vue'
|
||||
import type { IconName } from '../AppIcon.vue'
|
||||
import FolderContextMenu from './FolderContextMenu.vue'
|
||||
import RetentionLimitDialog from './RetentionLimitDialog.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
folder: Folder
|
||||
|
|
@ -19,8 +21,10 @@ const foldersStore = useFoldersStore()
|
|||
const accountsStore = useAccountsStore()
|
||||
const notificationsStore = useNotificationsStore()
|
||||
const messagesStore = useMessagesStore()
|
||||
const retentionStore = useRetentionStore()
|
||||
const expanded = ref(true)
|
||||
const contextMenu = ref<{ x: number; y: number } | null>(null)
|
||||
const showRetentionDialog = ref(false)
|
||||
|
||||
const isActive = computed(() => foldersStore.activeFolderId === props.folder.id)
|
||||
const hasChildren = computed(() => props.folder.children.length > 0)
|
||||
|
|
@ -32,6 +36,10 @@ const isMuted = computed(() => {
|
|||
if (!accountsStore.activeAccountId) return false
|
||||
return notificationsStore.isMuted(accountsStore.activeAccountId, props.folder.id)
|
||||
})
|
||||
const ownRetentionRule = computed(() => {
|
||||
if (!accountsStore.activeAccountId) return null
|
||||
return retentionStore.getOwnRule(accountsStore.activeAccountId, props.folder.id)
|
||||
})
|
||||
|
||||
const folderIcon = computed((): IconName => {
|
||||
switch (props.folder.role) {
|
||||
|
|
@ -83,6 +91,25 @@ function handleMarkAllRead(): void {
|
|||
}
|
||||
contextMenu.value = null
|
||||
}
|
||||
|
||||
function handleEditRetention(): void {
|
||||
contextMenu.value = null
|
||||
showRetentionDialog.value = true
|
||||
}
|
||||
|
||||
function handleRemoveRetention(): void {
|
||||
if (accountsStore.activeAccountId) {
|
||||
retentionStore.removeRule(accountsStore.activeAccountId, props.folder.id)
|
||||
}
|
||||
contextMenu.value = null
|
||||
}
|
||||
|
||||
function handleSaveRetention(maxMessages: number, recursive: boolean): void {
|
||||
if (accountsStore.activeAccountId) {
|
||||
retentionStore.setRule(accountsStore.activeAccountId, props.folder.id, maxMessages, recursive)
|
||||
}
|
||||
showRetentionDialog.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -120,10 +147,21 @@ function handleMarkAllRead(): void {
|
|||
:folder-id="folder.id"
|
||||
:folder-name="folder.name"
|
||||
:is-muted="isMuted"
|
||||
:has-retention-rule="!!ownRetentionRule"
|
||||
@close="closeContextMenu"
|
||||
@mute="handleMute"
|
||||
@unmute="handleUnmute"
|
||||
@mark-all-read="handleMarkAllRead"
|
||||
@edit-retention="handleEditRetention"
|
||||
@remove-retention="handleRemoveRetention"
|
||||
/>
|
||||
|
||||
<RetentionLimitDialog
|
||||
v-if="showRetentionDialog"
|
||||
:folder-name="folder.name"
|
||||
:initial-rule="ownRetentionRule"
|
||||
@close="showRetentionDialog = false"
|
||||
@save="handleSaveRetention"
|
||||
/>
|
||||
|
||||
<div v-if="hasChildren && expanded" class="folder-children">
|
||||
|
|
|
|||
395
src/renderer/src/components/sidebar/RetentionLimitDialog.vue
Normal file
395
src/renderer/src/components/sidebar/RetentionLimitDialog.vue
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import type { FolderRetentionRule } from '@shared/types/retention'
|
||||
|
||||
const props = defineProps<{
|
||||
folderName: string
|
||||
initialRule: FolderRetentionRule | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: []
|
||||
save: [maxMessages: number, recursive: boolean]
|
||||
}>()
|
||||
|
||||
const maxMessages = ref(props.initialRule?.maxMessages ?? 500)
|
||||
const recursive = ref(props.initialRule?.recursive ?? true)
|
||||
|
||||
const isValid = computed(() => Number.isInteger(maxMessages.value) && maxMessages.value >= 1)
|
||||
|
||||
function handleSubmit(): void {
|
||||
if (!isValid.value) return
|
||||
emit('save', maxMessages.value, recursive.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="dialog-overlay" @click.self="emit('close')">
|
||||
<div class="dialog">
|
||||
<div class="dialog-header">
|
||||
<div class="header-text">
|
||||
<h2>Лимит сообщений</h2>
|
||||
<p class="header-sub">{{ folderName }}</p>
|
||||
</div>
|
||||
<button class="close-btn" @click="emit('close')">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="dialog-body">
|
||||
<form @submit.prevent="handleSubmit">
|
||||
<div class="form-group">
|
||||
<label>Хранить последних сообщений</label>
|
||||
<input v-model.number="maxMessages" type="number" min="1" step="1" required />
|
||||
<p class="field-hint">При проверке письма старше этого числа удаляются безвозвратно</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="checkbox-label">
|
||||
<input v-model="recursive" type="checkbox" />
|
||||
Применить рекурсивно ко всем вложенным папкам
|
||||
</label>
|
||||
<p class="field-hint">Действует, пока во вложенной папке не задан собственный лимит</p>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="submit-btn" :disabled="!isValid">
|
||||
Сохранить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dialog-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(9, 9, 14, 0.45);
|
||||
backdrop-filter: blur(20px) saturate(1.6);
|
||||
-webkit-backdrop-filter: blur(20px) saturate(1.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
animation: overlay-in 180ms ease;
|
||||
}
|
||||
|
||||
@keyframes overlay-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.dialog {
|
||||
position: relative;
|
||||
width: 380px;
|
||||
max-width: 96vw;
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
backdrop-filter: blur(72px) saturate(2.8);
|
||||
-webkit-backdrop-filter: blur(72px) saturate(2.8);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.60),
|
||||
inset 0 3px 16px rgba(255, 255, 255, 0.05),
|
||||
inset 1px 0 0 rgba(255, 255, 255, 0.08),
|
||||
inset -1px 0 0 rgba(255, 255, 255, 0.05),
|
||||
inset 0 -1px 0 rgba(0, 0, 0, 0.20),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.14),
|
||||
0 8px 32px rgba(0, 0, 0, 0.45),
|
||||
0 32px 80px rgba(0, 0, 0, 0.65);
|
||||
animation: dialog-in 280ms cubic-bezier(0.34, 1.15, 0.64, 1);
|
||||
}
|
||||
|
||||
@keyframes dialog-in {
|
||||
from { opacity: 0; transform: scale(0.92) translateY(14px); }
|
||||
to { opacity: 1; transform: scale(1) translateY(0); }
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 18px 20px;
|
||||
background: linear-gradient(to bottom, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.04) 100%);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.10);
|
||||
}
|
||||
|
||||
.header-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.header-text h2 {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.2px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.header-sub {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin: 3px 0 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
color: var(--text-muted);
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.12);
|
||||
transition: background var(--transition-fast), color var(--transition-fast);
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-group label:not(.checkbox-label) {
|
||||
display: block;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
color: rgba(255, 255, 255, 0.38);
|
||||
margin-bottom: 6px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.6px;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
margin: 5px 0 0;
|
||||
}
|
||||
|
||||
.form-group input[type="number"] {
|
||||
width: 100%;
|
||||
padding: 11px 13px;
|
||||
font-size: 14px;
|
||||
border-radius: var(--radius-md);
|
||||
background: rgba(0, 0, 0, 0.22);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-top-color: rgba(0, 0, 0, 0.30);
|
||||
color: var(--text-primary);
|
||||
box-shadow: inset 0 2px 6px rgba(0,0,0,0.28), 0 1px 0 rgba(255,255,255,0.07);
|
||||
transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
background: rgba(0, 0, 0, 0.28);
|
||||
border-color: color-mix(in srgb, var(--accent) 50%, transparent);
|
||||
border-top-color: rgba(0, 0, 0, 0.25);
|
||||
box-shadow:
|
||||
inset 0 2px 6px rgba(0,0,0,0.22),
|
||||
0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent),
|
||||
0 1px 0 rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.checkbox-label input[type="checkbox"] {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
min-width: 15px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
border-radius: var(--radius-xs);
|
||||
background: rgba(0, 0, 0, 0.22);
|
||||
border: 1px solid rgba(255, 255, 255, 0.09);
|
||||
border-top-color: rgba(0, 0, 0, 0.28);
|
||||
box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
|
||||
transition: background var(--transition-fast);
|
||||
}
|
||||
|
||||
.checkbox-label input[type="checkbox"]:checked {
|
||||
background: var(--accent);
|
||||
border-color: color-mix(in srgb, var(--accent) 60%, rgba(0,0,0,0.5));
|
||||
}
|
||||
|
||||
.checkbox-label input[type="checkbox"]:checked::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
top: 1px;
|
||||
width: 4px;
|
||||
height: 7px;
|
||||
border: 1.5px solid #0d1a00;
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border-radius: var(--radius-md);
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
margin-top: 4px;
|
||||
color: var(--accent-text);
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
color-mix(in srgb, var(--accent) 88%, white 12%) 0%,
|
||||
var(--accent) 100%
|
||||
);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.40),
|
||||
inset 0 -1px 0 rgba(0,0,0,0.12),
|
||||
0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent);
|
||||
transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
|
||||
}
|
||||
|
||||
.submit-btn:hover:not(:disabled) {
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
color-mix(in srgb, var(--accent-hover) 88%, white 12%) 0%,
|
||||
var(--accent-hover) 100%
|
||||
);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255,255,255,0.45),
|
||||
0 4px 18px color-mix(in srgb, var(--accent) 40%, transparent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.submit-btn:active:not(:disabled) { transform: translateY(0); }
|
||||
|
||||
.submit-btn:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ── Material 3 ── */
|
||||
html[data-design='material3'] .dialog-overlay {
|
||||
background: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .dialog {
|
||||
background: var(--md-sys-color-surface-container-high);
|
||||
border-radius: var(--md-sys-shape-corner-extra-large);
|
||||
box-shadow: var(--md-sys-elevation-3);
|
||||
animation-duration: var(--md-sys-motion-duration-medium4);
|
||||
animation-timing-function: var(--md-sys-motion-easing-emphasized-decelerate);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .dialog-header {
|
||||
background: transparent;
|
||||
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .header-text h2 {
|
||||
font-size: var(--md-sys-typescale-headline-small-size);
|
||||
line-height: var(--md-sys-typescale-headline-small-line);
|
||||
font-weight: var(--md-sys-typescale-headline-small-weight);
|
||||
letter-spacing: var(--md-sys-typescale-headline-small-tracking);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .header-sub {
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .close-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .close-btn:hover {
|
||||
background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .form-group label:not(.checkbox-label) {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
font-weight: var(--md-sys-typescale-body-small-weight);
|
||||
letter-spacing: var(--md-sys-typescale-body-small-tracking);
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
html[data-design='material3'] .field-hint {
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .form-group input[type="number"] {
|
||||
background: var(--md-sys-color-surface-container-highest);
|
||||
border: 1px solid var(--md-sys-color-outline);
|
||||
border-top-color: var(--md-sys-color-outline);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
box-shadow: none;
|
||||
border-radius: var(--md-sys-shape-corner-small);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .form-group input:focus {
|
||||
background: var(--md-sys-color-surface-container-highest);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
border-top-color: var(--md-sys-color-primary);
|
||||
box-shadow: 0 0 0 1px var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .checkbox-label {
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .checkbox-label input[type="checkbox"] {
|
||||
background: transparent;
|
||||
border: 2px solid var(--md-sys-color-outline);
|
||||
border-top-color: var(--md-sys-color-outline);
|
||||
box-shadow: none;
|
||||
border-radius: var(--md-sys-shape-corner-extra-small);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .checkbox-label input[type="checkbox"]:checked {
|
||||
background: var(--md-sys-color-primary);
|
||||
border-color: var(--md-sys-color-primary);
|
||||
}
|
||||
|
||||
html[data-design='material3'] .checkbox-label input[type="checkbox"]:checked::after {
|
||||
border-color: var(--md-sys-color-on-primary);
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
html[data-design='material3'] .submit-btn {
|
||||
border-radius: var(--md-sys-shape-corner-full);
|
||||
font-size: var(--md-sys-typescale-label-large-size);
|
||||
font-weight: var(--md-sys-typescale-label-large-weight);
|
||||
letter-spacing: var(--md-sys-typescale-label-large-tracking);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
html[data-design='material3'] .submit-btn:hover:not(:disabled) {
|
||||
box-shadow: var(--md-sys-elevation-1);
|
||||
}
|
||||
</style>
|
||||
82
src/renderer/src/stores/retention.store.ts
Normal file
82
src/renderer/src/stores/retention.store.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { ref, watch } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import type { Folder } from '@shared/types/folder'
|
||||
import type { FolderRetentionRule } from '@shared/types/retention'
|
||||
import { useFoldersStore } from './folders.store'
|
||||
import { useAccountsStore } from './accounts.store'
|
||||
import { useIpc } from '../composables/useIpc'
|
||||
|
||||
export const useRetentionStore = defineStore('retention', () => {
|
||||
const { invoke } = useIpc()
|
||||
const accountsStore = useAccountsStore()
|
||||
|
||||
// Record<"accountId:folderId", FolderRetentionRule>
|
||||
const rules = ref<Record<string, FolderRetentionRule>>({})
|
||||
const loadedAccounts = new Set<string>()
|
||||
|
||||
function ruleKey(accountId: string, folderId: string): string {
|
||||
return `${accountId}:${folderId}`
|
||||
}
|
||||
|
||||
async function loadRules(accountId: string): Promise<void> {
|
||||
if (loadedAccounts.has(accountId)) return
|
||||
loadedAccounts.add(accountId)
|
||||
const list = await invoke('retention:list', { accountId })
|
||||
for (const rule of list) {
|
||||
rules.value[ruleKey(rule.accountId, rule.folderId)] = rule
|
||||
}
|
||||
}
|
||||
|
||||
function getOwnRule(accountId: string, folderId: string): FolderRetentionRule | null {
|
||||
return rules.value[ruleKey(accountId, folderId)] ?? null
|
||||
}
|
||||
|
||||
function findFolderById(folders: Folder[], id: string): Folder | null {
|
||||
for (const f of folders) {
|
||||
if (f.id === id) return f
|
||||
if (f.children.length > 0) {
|
||||
const found = findFolderById(f.children, id)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Правило, реально применяемое к папке: собственное — или ближайшее правило предка с recursive: true
|
||||
function getEffectiveRule(accountId: string, folderId: string): FolderRetentionRule | null {
|
||||
const own = getOwnRule(accountId, folderId)
|
||||
if (own) return own
|
||||
|
||||
const foldersStore = useFoldersStore()
|
||||
const allFolders = foldersStore.foldersByAccount[accountId] ?? []
|
||||
|
||||
let currentId = findFolderById(allFolders, folderId)?.parentId ?? null
|
||||
while (currentId !== null) {
|
||||
const rule = getOwnRule(accountId, currentId)
|
||||
if (rule && rule.recursive) return rule
|
||||
currentId = findFolderById(allFolders, currentId)?.parentId ?? null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function setRule(accountId: string, folderId: string, maxMessages: number, recursive: boolean): Promise<void> {
|
||||
const rule: FolderRetentionRule = { accountId, folderId, maxMessages, recursive }
|
||||
await invoke('retention:set', rule)
|
||||
rules.value[ruleKey(accountId, folderId)] = rule
|
||||
}
|
||||
|
||||
async function removeRule(accountId: string, folderId: string): Promise<void> {
|
||||
await invoke('retention:remove', { accountId, folderId })
|
||||
delete rules.value[ruleKey(accountId, folderId)]
|
||||
}
|
||||
|
||||
watch(
|
||||
() => accountsStore.activeAccountId,
|
||||
(accountId) => {
|
||||
if (accountId) loadRules(accountId)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
return { rules, getOwnRule, getEffectiveRule, setRule, removeRule }
|
||||
})
|
||||
|
|
@ -2,6 +2,7 @@ import type { AccountConfig } from './account'
|
|||
import type { FolderListResult, MessageListResult } from './provider'
|
||||
import type { MessageBody, MessageFlags, MessageEnvelope, ComposeData, ComposeSession } from './message'
|
||||
import type { CalendarInfo, CalendarEvent } from './calendar'
|
||||
import type { FolderRetentionRule, RetentionCleanupResult } from './retention'
|
||||
|
||||
export interface IpcChannelMap {
|
||||
'accounts:list': [void, AccountConfig[]]
|
||||
|
|
@ -67,6 +68,11 @@ export interface IpcChannelMap {
|
|||
'update:check': [void, { hasUpdate: boolean; version?: string; notes?: string }]
|
||||
'update:download': [void, void]
|
||||
'update:install': [void, void]
|
||||
|
||||
'retention:list': [{ accountId: string }, FolderRetentionRule[]]
|
||||
'retention:set': [FolderRetentionRule, void]
|
||||
'retention:remove': [{ accountId: string; folderId: string }, void]
|
||||
'retention:setCheckInterval': [{ minutes: number }, void]
|
||||
}
|
||||
|
||||
export interface IpcEventMap {
|
||||
|
|
@ -78,6 +84,7 @@ export interface IpcEventMap {
|
|||
'update:progress': { percent: number; transferred: number; total: number }
|
||||
'update:downloaded': Record<string, never>
|
||||
'update:error': { error: string }
|
||||
'retention:cleaned': { accountId: string; results: RetentionCleanupResult[] }
|
||||
}
|
||||
|
||||
export type IpcChannel = keyof IpcChannelMap
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type { Folder } from './folder'
|
||||
import type { MessageEnvelope, MessageBody, MessageFlags, ComposeData } from './message'
|
||||
import type { FolderRetentionRule, RetentionCleanupResult } from './retention'
|
||||
|
||||
export interface FolderListResult {
|
||||
folders: Folder[]
|
||||
|
|
@ -34,4 +35,5 @@ export interface IEmailProvider {
|
|||
pollNewMessages(): Promise<void>
|
||||
searchMessages(query: string, limit: number): Promise<MessageEnvelope[]>
|
||||
sendMessage(compose: ComposeData): Promise<void>
|
||||
enforceRetention(rules: FolderRetentionRule[]): Promise<RetentionCleanupResult[]>
|
||||
}
|
||||
|
|
|
|||
14
src/shared/types/retention.ts
Normal file
14
src/shared/types/retention.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Правило хранения писем: превышение maxMessages удаляет старые письма, оставляя последние N.
|
||||
// recursive === true — правило распространяется на все дочерние папки, пока не встретится
|
||||
// более близкое собственное правило.
|
||||
export interface FolderRetentionRule {
|
||||
accountId: string
|
||||
folderId: string
|
||||
maxMessages: number
|
||||
recursive: boolean
|
||||
}
|
||||
|
||||
export interface RetentionCleanupResult {
|
||||
folderId: string
|
||||
deletedCount: number
|
||||
}
|
||||
Loading…
Reference in a new issue