changeset 26401:f493fc8d3433

lib-smtp: smtp-server-recipient - Add smtp_server_recipient_get_reply() and use it.
author Stephan Bosch <stephan.bosch@dovecot.fi>
date Sat, 16 Mar 2019 16:24:59 +0100
parents 2848f5201ab6
children 07c851d96878
files src/lib-smtp/smtp-server-recipient.c src/lib-smtp/smtp-server.h
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-smtp/smtp-server-recipient.c	Sat Mar 16 14:41:37 2019 +0100
+++ b/src/lib-smtp/smtp-server-recipient.c	Sat Mar 16 16:24:59 2019 +0100
@@ -134,14 +134,9 @@
 
 void smtp_server_recipient_data_replied(struct smtp_server_recipient *rcpt)
 {
-	unsigned int reply_index = 0;
-
 	if (rcpt->replied)
 		return;
-	if (HAS_ALL_BITS(rcpt->trans->flags,
-			 SMTP_SERVER_TRANSACTION_FLAG_REPLY_PER_RCPT))
-		reply_index = rcpt->index;
-	if (smtp_server_command_get_reply(rcpt->cmd->cmd, reply_index) == NULL)
+	if (smtp_server_recipient_get_reply(rcpt) == NULL)
 		return;
 	rcpt->replied = TRUE;
 	if (!smtp_server_recipient_call_hooks(
@@ -150,6 +145,15 @@
 	}
 }
 
+struct smtp_server_reply *
+smtp_server_recipient_get_reply(struct smtp_server_recipient *rcpt)
+{
+	if (!HAS_ALL_BITS(rcpt->trans->flags,
+			 SMTP_SERVER_TRANSACTION_FLAG_REPLY_PER_RCPT))
+		return smtp_server_command_get_reply(rcpt->cmd->cmd, 0);
+	return smtp_server_command_get_reply(rcpt->cmd->cmd, rcpt->index);
+}
+
 bool smtp_server_recipient_is_replied(struct smtp_server_recipient *rcpt)
 {
 	i_assert(rcpt->cmd != NULL);
--- a/src/lib-smtp/smtp-server.h	Sat Mar 16 14:41:37 2019 +0100
+++ b/src/lib-smtp/smtp-server.h	Sat Mar 16 16:24:59 2019 +0100
@@ -86,6 +86,8 @@
 };
 ARRAY_DEFINE_TYPE(smtp_server_recipient, struct smtp_server_recipient *);
 
+struct smtp_server_reply *
+smtp_server_recipient_get_reply(struct smtp_server_recipient *rcpt);
 bool smtp_server_recipient_is_replied(struct smtp_server_recipient *rcpt);
 void smtp_server_recipient_replyv(struct smtp_server_recipient *rcpt,
 				  unsigned int status, const char *enh_code,