From 30a47a336c0b8a934bc3934fd3b1862fb10eaff8 Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 25 Jul 2022 02:00:00 +0200 Subject: [PATCH] Fix using wrong sequence counter for key replies --- .../dispatch-app-logic-action/replytokeyrequest.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/function/sync/apply-actions/dispatch-app-logic-action/replytokeyrequest.ts b/src/function/sync/apply-actions/dispatch-app-logic-action/replytokeyrequest.ts index f6c6ad5..a9c49c4 100644 --- a/src/function/sync/apply-actions/dispatch-app-logic-action/replytokeyrequest.ts +++ b/src/function/sync/apply-actions/dispatch-app-logic-action/replytokeyrequest.ts @@ -18,7 +18,7 @@ import { ReplyToKeyRequestAction } from '../../../../action' import { Cache } from '../cache' import { EventHandler } from '../../../../monitoring/eventhandler' -import { SourceDeviceNotFoundException } from '../exception/illegal-state' +import { IllegalStateException } from '../exception/illegal-state' export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache, eventHandler }: { deviceId: string @@ -65,14 +65,16 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache const deviceEntryUnsafe = await cache.database.device.findOne({ where: { familyId: cache.familyId, - deviceId + deviceId: request.senderDeviceId }, transaction: cache.transaction, attributes: ['nextKeyReplySequenceNumber'] }) if (!deviceEntryUnsafe) { - throw new SourceDeviceNotFoundException() + throw new IllegalStateException({ + staticMessage: 'target device entry not found' + }) } const deviceEntry = { @@ -84,7 +86,7 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache }, { where: { familyId: cache.familyId, - deviceId + deviceId: request.senderDeviceId }, transaction: cache.transaction })