summaryrefslogtreecommitdiffstats
path: root/src/submission/submission-recipient.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/submission/submission-recipient.c
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/submission/submission-recipient.c')
-rw-r--r--src/submission/submission-recipient.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/submission/submission-recipient.c b/src/submission/submission-recipient.c
new file mode 100644
index 0000000..a49b038
--- /dev/null
+++ b/src/submission/submission-recipient.c
@@ -0,0 +1,55 @@
+/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
+
+#include "submission-common.h"
+
+#include "submission-backend.h"
+#include "submission-recipient.h"
+
+struct submission_recipient_module_register
+submission_recipient_module_register = { 0 };
+
+static void
+submission_recipient_approved(struct smtp_server_recipient *rcpt ATTR_UNUSED,
+ struct submission_recipient *srcpt);
+
+struct submission_recipient *
+submission_recipient_create(struct client *client,
+ struct smtp_server_recipient *rcpt)
+{
+ struct submission_recipient *srcpt;
+
+ srcpt = p_new(rcpt->pool, struct submission_recipient, 1);
+ srcpt->rcpt = rcpt;
+ srcpt->backend = client->state.backend;
+
+ rcpt->context = srcpt;
+
+ p_array_init(&srcpt->module_contexts, rcpt->pool, 5);
+
+ smtp_server_recipient_add_hook(
+ rcpt, SMTP_SERVER_RECIPIENT_HOOK_APPROVED,
+ submission_recipient_approved, srcpt);
+
+ return srcpt;
+}
+
+static void
+submission_recipient_approved(struct smtp_server_recipient *rcpt ATTR_UNUSED,
+ struct submission_recipient *srcpt)
+{
+ struct submission_backend *backend = srcpt->backend;
+ struct client *client = backend->client;
+ struct submission_backend *rcpt_backend;
+ bool backend_found = FALSE;
+
+ array_push_back(&client->rcpt_to, &srcpt);
+
+ array_foreach_elem(&client->rcpt_backends, rcpt_backend) {
+ if (rcpt_backend == backend) {
+ backend_found = TRUE;
+ break;
+ }
+ }
+ if (!backend_found)
+ array_push_back(&client->rcpt_backends, &backend);
+}