fix: let plugins answer invitations found by a search of the user's own mail

This commit is contained in:
Linus Rath
2026-11-02 23:20:54 +01:00
parent fd30fdcd27
commit d3d150d2c4
2 changed files with 10 additions and 2 deletions
@@ -92,6 +92,13 @@ describe('api.calendar.respond', () => {
expect(store.rsvpEvent).not.toHaveBeenCalled();
});
it('answers a message the list names with the account of the user', async () => {
// Search results carry their account, the user's own one included.
useEmailStore.setState({ emails: [{ id: 'inv', sourceClientAccountId: 'login1', sourceAccountId: 'acc1' }] } as never);
useAuthStore.setState({ getClientForAccount: () => client } as never);
await expect(call(ASSISTANT, 'calendar.respond', 'inv', 'accepted')).resolves.toMatchObject({ status: 'accepted' });
});
it('refuses mail of another account, a bad status and plugins without calendar:respond', async () => {
useEmailStore.setState({ emails: [{ id: 'inv', sourceClientAccountId: 'login1', sourceAccountId: 'acc2' }] } as never);
useAuthStore.setState({ getClientForAccount: () => client } as never);
+3 -2
View File
@@ -65,8 +65,9 @@ export async function doCalendarRespond(emailIdArg: unknown, statusArg: unknown)
const named = await readNamedEmail(client, emailId, method);
if (!named) throw new Error(`${method}: no message with id "${emailId}"`);
// Mail of a shared or group mailbox is answered as that account: only in the reader.
if (named.accountId !== undefined) throw new Error(`${method}: answer invitations of other accounts in the reader`);
// Mail of a shared or group mailbox is answered as that account: only in
// the reader. Search results name the user's own account too.
if (named.accountId !== undefined && named.accountId !== client.getAccountId()) throw new Error(`${method}: answer invitations of other accounts in the reader`);
const { email } = named;
const invitation = await readOwnInvitation(client, email);