Skip to content
Snippets Groups Projects
Commit c8e6ae68 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Allow subject to be changed when forwarding mail, support fwd-to QWKnet

The new messages subject may be passed into forwardmail(). If it isn't, it'll be prompted for (defaulting to the original message subject).

Also, fix forwarding to QWKnet (look-up full-route/to-user-number).
parent bc6cddb0
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #982 passed
...@@ -681,7 +681,7 @@ public: ...@@ -681,7 +681,7 @@ public:
bool msgabort(void); bool msgabort(void);
bool email(int usernumber, const char *top = NULL, const char *title = NULL bool email(int usernumber, const char *top = NULL, const char *title = NULL
, long mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL); , long mode = WM_NONE, smb_t* resmb = NULL, smbmsg_t* remsg = NULL);
bool forwardmail(smbmsg_t* msg, const char* to, const char* comment = NULL); bool forwardmail(smbmsg_t* msg, const char* to, const char* subject = NULL, const char* comment = NULL);
void removeline(char *str, char *str2, char num, char skip); void removeline(char *str, char *str2, char num, char skip);
ulong msgeditor(char *buf, const char *top, char *title); ulong msgeditor(char *buf, const char *top, char *title);
bool editfile(char *path, bool msg=false); bool editfile(char *path, bool msg=false);
......
...@@ -1331,10 +1331,11 @@ bool sbbs_t::copyfattach(uint to, uint from, const char* subj) ...@@ -1331,10 +1331,11 @@ bool sbbs_t::copyfattach(uint to, uint from, const char* subj)
/* If comment is NULL, comment lines will be prompted for. */ /* If comment is NULL, comment lines will be prompted for. */
/* If comment is a zero-length string, no comments will be included. */ /* If comment is a zero-length string, no comments will be included. */
/****************************************************************************/ /****************************************************************************/
bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* comment) bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* subject, const char* comment)
{ {
char str[256],touser[128]; char str[256],touser[128];
char tmp[512]; char tmp[512];
char subj[LEN_TITLE + 1];
int result; int result;
smbmsg_t msg; smbmsg_t msg;
node_t node; node_t node;
...@@ -1372,13 +1373,21 @@ bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* comment) ...@@ -1372,13 +1373,21 @@ bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* comment)
return false; return false;
} }
if(subject == NULL) {
subject = subj;
SAFECOPY(subj, orgmsg->subj);
bputs(text[SubjectPrompt]);
if(!getstr(subj, sizeof(subj) - 1, K_LINE | K_EDIT | K_AUTODEL | K_TRIM))
return false;
}
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
msg.hdr.auxattr = orgmsg->hdr.auxattr & (MSG_HFIELDS_UTF8 | MSG_MIMEATTACH); msg.hdr.auxattr = orgmsg->hdr.auxattr & (MSG_HFIELDS_UTF8 | MSG_MIMEATTACH);
msg.hdr.when_imported.time = time32(NULL); msg.hdr.when_imported.time = time32(NULL);
msg.hdr.when_imported.zone = sys_timezone(&cfg); msg.hdr.when_imported.zone = sys_timezone(&cfg);
msg.hdr.when_written = msg.hdr.when_imported; msg.hdr.when_written = msg.hdr.when_imported;
smb_hfield_str(&msg, SUBJECT, orgmsg->subj); smb_hfield_str(&msg, SUBJECT, subject);
add_msg_ids(&cfg, &smb, &msg, orgmsg); add_msg_ids(&cfg, &smb, &msg, orgmsg);
smb_hfield_str(&msg,SENDER,useron.alias); smb_hfield_str(&msg,SENDER,useron.alias);
...@@ -1396,15 +1405,29 @@ bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* comment) ...@@ -1396,15 +1405,29 @@ bool sbbs_t::forwardmail(smbmsg_t* orgmsg, const char* to, const char* comment)
smb_hfield_str(&msg, RECIPIENTEXT,str); smb_hfield_str(&msg, RECIPIENTEXT,str);
} else { } else {
SAFECOPY(touser, to); SAFECOPY(touser, to);
char* addr = touser; char* p;
char* p = strchr(addr, '@'); if((p = strchr(touser, '@')) != NULL)
if(net_type != NET_INTERNET && p != NULL)
addr = p + 1;
smb_hfield_netaddr(&msg, RECIPIENTNETADDR, addr, NULL);
if(p != NULL)
*p = '\0'; *p = '\0';
smb_hfield_str(&msg, RECIPIENT, touser); smb_hfield_str(&msg, RECIPIENT, touser);
SAFECOPY(touser, to); SAFECOPY(touser, to);
const char* addr = touser;
if(net_type != NET_INTERNET && p != NULL)
addr = p + 1;
char fulladdr[128];
if(net_type == NET_QWK) {
usernumber = qwk_route(&cfg, addr, fulladdr, sizeof(fulladdr) - 1);
if(*fulladdr == '\0') {
bprintf(text[InvalidNetMailAddr], addr);
smb_freemsgmem(&msg);
return false;
}
addr = fulladdr;
SAFEPRINTF(str, "%u", usernumber);
smb_hfield_str(&msg, RECIPIENTEXT, str);
usernumber = 0;
}
smb_hfield_bin(&msg, RECIPIENTNETTYPE, net_type);
smb_hfield_netaddr(&msg, RECIPIENTNETADDR, addr, &net_type);
} }
if(orgmsg->mime_version != NULL) { if(orgmsg->mime_version != NULL) {
safe_snprintf(str, sizeof(str), "MIME-Version: %s", orgmsg->mime_version); safe_snprintf(str, sizeof(str), "MIME-Version: %s", orgmsg->mime_version);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment