jcs
/subtext
/amendments
/421
mail: Bounce mail to sysop, tweak log messages
jcs made amendment 421 over 2 years ago
--- mail.c	Tue Mar 14 08:47:07 2023
+++ mail.c	Wed Mar 15 14:10:16 2023
@@ -856,14 +856,14 @@ mail_toss_ftn_message(struct fidopkt_message *ftnmsg)
 	char *data;
 
 	if (db->config.ftn_node_addr[0] == 0) {
-		logger_printf("[mail] local FTN node address must be "
+		logger_printf("[mail] Local FTN node address must be "
 		  "configured in settings");
 		return -1;
 	}
 	
 	if (!fidopkt_parse_address(db->config.ftn_node_addr,
 	  &our_address)) {
-		logger_printf("[mail] failed parsing local FTN node address "
+		logger_printf("[mail] Failed parsing local FTN node address "
 		  "\"%s\", fix in settings", db->config.ftn_node_addr);
 		return -1;
 	}
@@ -881,14 +881,15 @@ mail_toss_ftn_message(struct fidopkt_message *ftnmsg)
 	}
 
 	to = user_find_by_username(ftnmsg->to);
-	if (to == NULL && strcasecmp(ftnmsg->to, "sysop") == 0)
-		to = user_find_by_username(user_first_sysop_username());
 	if (to == NULL) {
-		/* TODO: Should these go to sysop? */
-		logger_printf("[mail] no local user \"%s\", discarding message",
-		  ftnmsg->to);
-		ret = 0;
-		goto done;
+		to = user_find_by_username(user_first_sysop_username());
+		if (to == NULL) {
+			logger_printf("[mail] Can't find sysop username?");
+			ret = 0;
+			goto done;
+		}
+		logger_printf("[mail] No local user \"%s\", bouncing to sysop %s",
+		  ftnmsg->to, to->username);
 	}
 
 	mail_find_ids_for_user(to, &nmail_ids, &mail_ids, 0, 0, false);
@@ -903,7 +904,7 @@ mail_toss_ftn_message(struct fidopkt_message *ftnmsg)
 		
 		if (memcmp(&msg.ftn_msgid, &ftnmsg->msgid,
 		  sizeof(struct fidopkt_msgid)) == 0) {
-			logger_printf("[mail] already have %s NetMail message %s "
+			logger_printf("[mail] Already have %s NetMail message %s "
 			  "(%ld), skipping", db->config.ftn_network,
 			  ftnmsg->msgid_orig, msg.id);
 			ret = 0;
@@ -936,7 +937,7 @@ mail_toss_ftn_message(struct fidopkt_message *ftnmsg)
 	strlcpy(msg.ftn_reply, ftnmsg->reply, sizeof(msg.ftn_reply));
 
 	if (mail_save(&msg) != 0) {
-		logger_printf("[binkp] failed saving %s NetMail message from "
+		logger_printf("[binkp] Failed saving %s NetMail message from "
 		  "%u:%u/%u.%u to local user %s", db->config.ftn_network,
 		  ftnmsg->header.orig.zone, ftnmsg->header.orig.net,
 		  ftnmsg->header.orig.node, ftnmsg->header.orig.point,
@@ -945,7 +946,7 @@ mail_toss_ftn_message(struct fidopkt_message *ftnmsg)
 		goto done;
 	}
 	
-	logger_printf("[binkp] tossed %s NetMail from %u:%u/%u.%u to local "
+	logger_printf("[binkp] Tossed %s NetMail from %u:%u/%u.%u to local "
 	  "user %s", db->config.ftn_network,
 	  ftnmsg->header.orig.zone, ftnmsg->header.orig.net,
 	  ftnmsg->header.orig.node, ftnmsg->header.orig.point, to->username);