From e3622114054c45a4a83822b708be8a2ee3ceb140 Mon Sep 17 00:00:00 2001 From: Wassilios Lytras Date: Tue, 19 Mar 2024 17:32:35 +0100 Subject: [PATCH] Remove obsolete checks --- pyas2lib/as2.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pyas2lib/as2.py b/pyas2lib/as2.py index ea288b0..190c439 100644 --- a/pyas2lib/as2.py +++ b/pyas2lib/as2.py @@ -620,18 +620,16 @@ async def aparse( else: self.receiver, self.sender = find_org_partner_cb(org_id, partner_id) - else: - if find_org_cb: - if inspect.iscoroutinefunction(find_org_cb): - self.receiver = await find_org_cb(org_id) - else: - self.receiver = find_org_cb(org_id) + elif find_org_cb and find_partner_cb: + if inspect.iscoroutinefunction(find_org_cb): + self.receiver = await find_org_cb(org_id) + else: + self.receiver = find_org_cb(org_id) - if find_partner_cb: - if inspect.iscoroutinefunction(find_partner_cb): - self.sender = await find_partner_cb(partner_id) - else: - self.sender = find_partner_cb(partner_id) + if inspect.iscoroutinefunction(find_partner_cb): + self.sender = await find_partner_cb(partner_id) + else: + self.sender = find_partner_cb(partner_id) if not self.receiver: raise PartnerNotFound(f"Unknown AS2 organization with id {org_id}") @@ -980,13 +978,12 @@ async def aparse(self, raw_content, find_message_cb): self.orig_message_id, orig_recipient = self.detect_mdn() # Call the find message callback which should return a Message instance - if find_message_cb: - if inspect.iscoroutinefunction(find_message_cb): - orig_message = await find_message_cb( - self.orig_message_id, orig_recipient - ) - else: - orig_message = find_message_cb(self.orig_message_id, orig_recipient) + if inspect.iscoroutinefunction(find_message_cb): + orig_message = await find_message_cb( + self.orig_message_id, orig_recipient + ) + else: + orig_message = find_message_cb(self.orig_message_id, orig_recipient) if not orig_message: status = "failed/Failure"