Несколько ящиков у одного логина, общие ящики, кто ответил, вход ящик*логин
continuous-integration/drone/pr Build is passing
continuous-integration/drone/pr Build is passing
- V7: users.is_shared, mailbox_access (MEMBER от админа/Jambotron, ATTACHED по паролю ящика), messages.answered_by
- /api/mailboxes: мои ящики с непрочитанными, сессия другого ящика (JWT с claim by), подключить по паролю
(LoginGuard), убрать из меню
- общий ящик: без своего входа (веб/SMTP/IMAP), участники открывают; «прочитано» общее; ответ из веба → answered_by
- SMTP/IMAP: ящик*логин + пароль логина (как master user в Dovecot)
- открытый чужой ящик (общий, подключённый, OPEN админа): профиль и пароль не меняются (403)
- админ: создать shared, участники ящика (PUT /{id}/members); служебное API: PUT /shared/{address};
выключение аккаунта убирает и из общих ящиков
- UI: MAILBOXES в левом меню (переключение, ⊕ подключить, × убрать), shared/участники в настройках,
«Answered by» у письма
- 88 тестов; живой прогон на Postgres 17 (апгрейд V6→V7 на данных), скриншоты UI
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import { filter } from 'rxjs';
|
||||
import { ApiService } from '../../core/api.service';
|
||||
import { AuthService } from '../../core/auth.service';
|
||||
import { MailStateService } from '../../core/mail-state.service';
|
||||
import { Folder, errorText, folderIcon, folderLabel, formatBytes } from '../../core/models';
|
||||
import { Folder, MailboxEntry, errorText, folderIcon, folderLabel, formatBytes } from '../../core/models';
|
||||
import { BackgroundComponent } from '../../ui/background.component';
|
||||
import { DialogService } from '../../ui/dialog.service';
|
||||
import { THEMES, ThemeService } from '../../ui/theme.service';
|
||||
@@ -81,6 +81,44 @@ import { ToastService } from '../../ui/toast.service';
|
||||
<div class="flex-grow max-w-[1500px] w-full mx-auto p-3 md:p-5 grid grid-cols-1 lg:grid-cols-[260px_1fr] gap-5">
|
||||
<nav class="glass-panel static p-4 md:pt-6 h-fit lg:sticky lg:top-20 lg:block" [class.hidden]="!menuOpen()"
|
||||
aria-label="Mail folders">
|
||||
<div class="flex items-center justify-between mb-2 px-1">
|
||||
<h2 class="text-[11px] font-orbitron font-bold text-cyan-300 tracking-widest">MAILBOXES</h2>
|
||||
<button type="button" class="text-slate-400 hover:text-cyan-300" matTooltip="Add a mailbox you have the password of"
|
||||
aria-label="Add mailbox" [attr.aria-expanded]="attachOpen()" (click)="attachOpen.set(!attachOpen())">
|
||||
<mat-icon class="!text-xl">add_circle_outline</mat-icon></button>
|
||||
</div>
|
||||
<ul class="space-y-1 mb-3" aria-label="Your mailboxes">
|
||||
@for (b of boxes(); track b.email) {
|
||||
<li class="flex items-center gap-1">
|
||||
<button type="button" (click)="switchTo(b)" [attr.aria-current]="b.email === auth.email() ? 'true' : null"
|
||||
class="flex-grow flex items-center gap-2 px-3 py-1.5 rounded-lg border text-left font-rajdhani font-semibold min-w-0"
|
||||
[class.border-pink-500/40]="b.email === auth.email()" [class.bg-pink-500/15]="b.email === auth.email()"
|
||||
[class.text-pink-200]="b.email === auth.email()" [class.border-transparent]="b.email !== auth.email()"
|
||||
[class.text-slate-300]="b.email !== auth.email()"
|
||||
[matTooltip]="b.email + (b.shared ? ' — shared' : b.kind === 'ATTACHED' ? ' — attached' : '')">
|
||||
<mat-icon class="!text-lg shrink-0">{{ b.shared ? 'groups' : b.kind === 'OWN' ? 'person' : 'link' }}</mat-icon>
|
||||
<span class="flex-grow truncate text-sm">{{ b.email }}</span>
|
||||
@if (b.unread) {
|
||||
<span class="text-[11px] font-mono px-2 rounded-full bg-pink-500/25 text-pink-300" [attr.aria-label]="b.unread + ' unread'">{{ b.unread }}</span>
|
||||
}
|
||||
</button>
|
||||
@if (b.kind !== 'OWN') {
|
||||
<button type="button" class="text-slate-500 hover:text-pink-400" [attr.aria-label]="'Remove ' + b.email + ' from my mailboxes'"
|
||||
matTooltip="Remove from my mailboxes" (click)="leave(b)"><mat-icon class="!text-base">close</mat-icon></button>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@if (attachOpen()) {
|
||||
<form class="space-y-2 mb-4 p-2 rounded-lg border border-cyan-500/20" (ngSubmit)="attach()" aria-label="Add a mailbox">
|
||||
<label class="synth-label" for="att-email">Mailbox</label>
|
||||
<input id="att-email" name="attEmail" class="synth-input !py-1.5" [(ngModel)]="attachEmail" autocomplete="off" placeholder="name@domain">
|
||||
<label class="synth-label" for="att-pw">Its password</label>
|
||||
<input id="att-pw" name="attPw" type="password" class="synth-input !py-1.5" [(ngModel)]="attachPassword" autocomplete="off">
|
||||
<button type="submit" class="cyber-btn w-full py-1.5 rounded-lg text-xs font-bold"><mat-icon>link</mat-icon> ADD</button>
|
||||
</form>
|
||||
}
|
||||
|
||||
<a routerLink="/compose" class="cyber-btn w-full py-2.5 rounded-xl font-bold text-xs mb-4" (click)="menuOpen.set(false)">
|
||||
<mat-icon>edit</mat-icon> COMPOSE
|
||||
</a>
|
||||
@@ -165,6 +203,11 @@ export class ShellComponent {
|
||||
|
||||
readonly themes = THEMES;
|
||||
readonly menuOpen = signal(false);
|
||||
/** own, shared and attached mailboxes of the login (shown when there is more than the own one, or to add one) */
|
||||
readonly boxes = signal<MailboxEntry[]>([]);
|
||||
readonly attachOpen = signal(false);
|
||||
attachEmail = '';
|
||||
attachPassword = '';
|
||||
query = '';
|
||||
|
||||
readonly links = [
|
||||
@@ -195,7 +238,8 @@ export class ShellComponent {
|
||||
constructor() {
|
||||
this.state.refreshFolders();
|
||||
this.state.refreshProfile();
|
||||
const timer = setInterval(() => this.state.refreshFolders(), 30000);
|
||||
this.loadBoxes();
|
||||
const timer = setInterval(() => { this.state.refreshFolders(); this.loadBoxes(); }, 30000);
|
||||
inject(DestroyRef).onDestroy(() => clearInterval(timer));
|
||||
this.router.events.pipe(filter(e => e instanceof NavigationEnd)).subscribe(() => {
|
||||
const q = this.router.parseUrl(this.router.url).queryParams['q'];
|
||||
@@ -256,6 +300,52 @@ export class ShellComponent {
|
||||
}
|
||||
}
|
||||
|
||||
loadBoxes(): void {
|
||||
this.api.myMailboxes().subscribe({ next: list => this.boxes.set(list), error: () => {} });
|
||||
}
|
||||
|
||||
/** Another mailbox of this login: its session, full reload — fresh folders and profile. */
|
||||
switchTo(b: MailboxEntry): void {
|
||||
if (b.email === this.auth.email()) { this.router.navigate(['/']); return; }
|
||||
this.api.mailboxSession(b.email).subscribe({
|
||||
next: session => { this.state.reset(); this.auth.switchTo(session); location.assign('/'); },
|
||||
error: e => this.toasts.error(errorText(e))
|
||||
});
|
||||
}
|
||||
|
||||
attach(): void {
|
||||
const email = this.attachEmail.trim().toLowerCase();
|
||||
if (!email || !this.attachPassword) { this.toasts.error('Mailbox and its password'); return; }
|
||||
this.api.attachMailbox(email, this.attachPassword).subscribe({
|
||||
next: b => {
|
||||
this.attachEmail = this.attachPassword = '';
|
||||
this.attachOpen.set(false);
|
||||
this.toasts.ok(b.email + ' added to your mailboxes');
|
||||
this.loadBoxes();
|
||||
},
|
||||
error: e => this.toasts.error(errorText(e))
|
||||
});
|
||||
}
|
||||
|
||||
leave(b: MailboxEntry): void {
|
||||
this.dialogs.confirm(`Remove ${b.email}?`, b.shared
|
||||
? 'It disappears from your menu. An administrator can give it back.'
|
||||
: 'It disappears from your menu. Add it again with its password.', 'Remove', true).subscribe(ok => {
|
||||
if (ok === null) return;
|
||||
this.api.leaveMailbox(b.email).subscribe({
|
||||
next: () => {
|
||||
this.toasts.ok(b.email + ' removed');
|
||||
if (b.email === this.auth.email()) {
|
||||
const own = this.boxes().find(x => x.kind === 'OWN');
|
||||
if (own) { this.switchTo(own); return; }
|
||||
}
|
||||
this.loadBoxes();
|
||||
},
|
||||
error: e => this.toasts.error(errorText(e))
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
backToAdmin(): void {
|
||||
this.auth.backToAdmin();
|
||||
location.assign('/settings');
|
||||
|
||||
Reference in New Issue
Block a user