Commit 7a3d7797 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Remove Skip and Abort from ResponseMessages

These two are not valid returns from filters (although Skip is valid as
a message passed through channels from a filter as a message response).
parent 1c77387c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ class _TaskRunner:
			for _, session in self.filters:
				await session.deliver(message)

	async def message_events(self, message: _VALID_EVENT_MESSAGE) -> ResponseMessage:
	async def message_events(self, message: _VALID_EVENT_MESSAGE) -> ResponseMessage|Skip:
		skip = isinstance(message, Body)
		for channel in self.channels:
			await channel.send(message)
+2 −3
Original line number Diff line number Diff line
# Copyright 2022 Dominik Sekotill <dom.sekotill@kodo.org.uk>
# Copyright 2022-2023 Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -40,8 +40,7 @@ Messages sent from an MTA to a filter
"""

ResponseMessage: TypeAlias = Union[
	Continue, Reject, Discard, Accept, TemporaryFailure, Skip,
	ReplyCode, Abort,
	Continue, Reject, Discard, Accept, TemporaryFailure, ReplyCode,
]
"""
Messages send from a filter to an MTA in response to `EventMessages`
+2 −2
Original line number Diff line number Diff line
@@ -295,9 +295,9 @@ class RunnerTests(AsyncTestCase):
		Check that a runner closes cleanly when it receives an Abort
		"""
		@Runner
		async def test_filter(session: Session) -> Skip:
		async def test_filter(session: Session) -> Reject:
			await session.helo()
			return Skip()
			return Reject()

		async with trio.open_nursery() as tg, MockMessageStream() as stream_mock:
			tg.start_soon(test_filter, stream_mock.peer_stream)