mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 00:14:12 +00:00
fix: don't offer the auto-reply audience on a shared account #1152
This commit is contained in:
@@ -8,6 +8,7 @@ import { STALWART_VACATION_SCRIPT, mockStalwartAccount } from '@/lib/filters/__t
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
import { useFilterStore } from '@/stores/filter-store';
|
||||
import { useIdentityStore } from '@/stores/identity-store';
|
||||
import { useManagedAccountStore } from '@/stores/managed-account-store';
|
||||
import { useVacationStore } from '@/stores/vacation-store';
|
||||
import { VacationSettings } from '../vacation-settings';
|
||||
|
||||
@@ -62,6 +63,7 @@ const initial = {
|
||||
vacation: useVacationStore.getState(),
|
||||
filter: useFilterStore.getState(),
|
||||
identity: useIdentityStore.getState(),
|
||||
managed: useManagedAccountStore.getState(),
|
||||
};
|
||||
beforeEach(() => {
|
||||
toast.error.mockClear();
|
||||
@@ -72,6 +74,7 @@ afterEach(() => {
|
||||
useVacationStore.setState(initial.vacation, true);
|
||||
useFilterStore.setState(initial.filter, true);
|
||||
useIdentityStore.setState(initial.identity, true);
|
||||
useManagedAccountStore.setState(initial.managed, true);
|
||||
});
|
||||
|
||||
async function openCard(server: ReturnType<typeof stalwart>) {
|
||||
@@ -390,6 +393,13 @@ describe('who gets the auto-reply, in the vacation card', () => {
|
||||
expect(screen.queryByRole('combobox', { name: 'audience.label' })).toBeNull();
|
||||
});
|
||||
|
||||
it('is not offered on a shared account, whose domains the signed-in identities do not tell', async () => {
|
||||
withIdentities();
|
||||
useManagedAccountStore.setState({ managedAccountId: 'b' } as never);
|
||||
await openCard(stalwart([rule('a')]));
|
||||
expect(screen.queryByRole('combobox', { name: 'audience.label' })).toBeNull();
|
||||
});
|
||||
|
||||
it('answers external senders only', async () => {
|
||||
withIdentities();
|
||||
const server = stalwart([rule('a')]);
|
||||
|
||||
@@ -167,8 +167,10 @@ export function VacationSettings() {
|
||||
};
|
||||
|
||||
// Who gets the auto-reply as a save stores it: everyone, or the senders
|
||||
// from (or not from) the account's domains as they are now.
|
||||
const canNarrow = audienceAvailable && domains.length > 0;
|
||||
// from (or not from) the account's domains as they are now. The domains
|
||||
// come from the signed-in user's identities, so a managed (shared) account
|
||||
// offers no narrowing rather than one built from the wrong domains.
|
||||
const canNarrow = audienceAvailable && !managedAccountId && domains.length > 0;
|
||||
const audienceSettings = !canNarrow
|
||||
? undefined
|
||||
: audienceOnly === 'all' ? null : { only: audienceOnly, domains };
|
||||
|
||||
Reference in New Issue
Block a user