summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2025-04-28 05:15:31 +0200
committerGravatar grunfink2025-04-28 05:15:31 +0200
commitda0ce17f15e3bb0d3b9eb1442f036d8f549ceee8 (patch)
tree3a580db39ea0bdfe3f183f06e361f0e6d639fe5b
parentMastoapi: correctly communicate 'approve_followers'. (diff)
downloadpenes-snac2-da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8.tar.gz
penes-snac2-da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8.tar.xz
penes-snac2-da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8.zip
Email notifications are sent the old way if 'spawn_sendmail' is set to true.
-rw-r--r--activitypub.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index fbf7a1f..92e408b 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -2570,6 +2570,34 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2570int send_email(const xs_dict *mailinfo) 2570int send_email(const xs_dict *mailinfo)
2571/* invoke curl */ 2571/* invoke curl */
2572{ 2572{
2573 if (xs_is_true(xs_dict_get(srv_config, "spawn_sendmail"))) {
2574 const char *msg = xs_dict_get(mailinfo, "body");
2575 FILE *f;
2576 int status;
2577 int fds[2];
2578 pid_t pid;
2579
2580 if (pipe(fds) == -1) return -1;
2581 pid = vfork();
2582 if (pid == -1) return -1;
2583 else if (pid == 0) {
2584 dup2(fds[0], 0);
2585 close(fds[0]);
2586 close(fds[1]);
2587 execl("/usr/sbin/sendmail", "sendmail", "-t", (char *) NULL);
2588 _exit(1);
2589 }
2590 close(fds[0]);
2591 if ((f = fdopen(fds[1], "w")) == NULL) {
2592 close(fds[1]);
2593 return -1;
2594 }
2595 fprintf(f, "%s\n", msg);
2596 fclose(f);
2597 if (waitpid(pid, &status, 0) == -1) return -1;
2598 return status;
2599 }
2600
2573 const char 2601 const char
2574 *url = xs_dict_get(srv_config, "smtp_url"), 2602 *url = xs_dict_get(srv_config, "smtp_url"),
2575 *user = xs_dict_get(srv_config, "smtp_username"), 2603 *user = xs_dict_get(srv_config, "smtp_username"),