diff --git a/lib/__tests__/plugin-host-calendar-respond.test.ts b/lib/__tests__/plugin-host-calendar-respond.test.ts index f287ed136..43e486328 100644 --- a/lib/__tests__/plugin-host-calendar-respond.test.ts +++ b/lib/__tests__/plugin-host-calendar-respond.test.ts @@ -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); diff --git a/lib/plugin-sandbox/assistant/c.calendar.ts b/lib/plugin-sandbox/assistant/c.calendar.ts index 20d07c5e4..9c76f72de 100644 --- a/lib/plugin-sandbox/assistant/c.calendar.ts +++ b/lib/plugin-sandbox/assistant/c.calendar.ts @@ -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);