Send feedback menu option

This commit is contained in:
Andrew Pamment 2018-02-07 20:38:25 +10:00
parent e2f03c68c4
commit 02f4679387
8 changed files with 82 additions and 53 deletions

BIN
dist/ansis/logoff.ans vendored

Binary file not shown.

Binary file not shown.

View File

@ -6,3 +6,6 @@ COMMAND LOGOFF
HOTKEY N HOTKEY N
COMMAND PREVMENU COMMAND PREVMENU
HOTKEY F
COMMAND SENDFEEDBACK

3
dist/menus/main.mnu vendored
View File

@ -43,3 +43,6 @@ COMMAND SENDNODEMSG
HOTKEY G HOTKEY G
COMMAND SUBMENU COMMAND SUBMENU
DATA logoff DATA logoff
HOTKEY F
COMMAND SENDFEEDBACK

View File

@ -129,3 +129,5 @@ Finally, an optional SECLEVEL command indicates the required security level for
**GENWWWURLS** Generate and show WWW urls for the tagged files for web download. **GENWWWURLS** Generate and show WWW urls for the tagged files for web download.
**NLBROWSER** Browse the nodelist for the current conference. **NLBROWSER** Browse the nodelist for the current conference.
**SENDFEEDBACK** Send feedback to the Sysop.

View File

@ -315,6 +315,7 @@ extern void chat_system(struct user_record *user);
extern int mail_getemailcount(struct user_record *user); extern int mail_getemailcount(struct user_record *user);
extern void send_email(struct user_record *user); extern void send_email(struct user_record *user);
extern void list_emails(struct user_record *user); extern void list_emails(struct user_record *user);
extern void commit_email(char *recipient, char *subject, char *msg);
extern void download_zmodem(struct user_record *user, char *filename); extern void download_zmodem(struct user_record *user, char *filename);
extern void settings_menu(struct user_record *user); extern void settings_menu(struct user_record *user);

View File

@ -7,6 +7,7 @@
#include "bbs.h" #include "bbs.h"
extern struct bbs_config conf; extern struct bbs_config conf;
extern struct user_record *gUser;
struct email_msg { struct email_msg {
int id; int id;
@ -17,14 +18,11 @@ struct email_msg {
char *body; char *body;
}; };
void send_email(struct user_record *user) { void commit_email(char *recipient, char *subject, char *msg) {
char buffer[256]; char buffer[PATH_MAX];
sqlite3 *db; sqlite3 *db;
sqlite3_stmt *res; sqlite3_stmt *res;
int rc; int rc;
char *recipient;
char *subject;
char *msg;
char *csql = "CREATE TABLE IF NOT EXISTS email (" char *csql = "CREATE TABLE IF NOT EXISTS email ("
"id INTEGER PRIMARY KEY," "id INTEGER PRIMARY KEY,"
"sender TEXT COLLATE NOCASE," "sender TEXT COLLATE NOCASE,"
@ -36,6 +34,55 @@ void send_email(struct user_record *user) {
char *isql = "INSERT INTO email (sender, recipient, subject, body, date, seen) VALUES(?, ?, ?, ?, ?, 0)"; char *isql = "INSERT INTO email (sender, recipient, subject, body, date, seen) VALUES(?, ?, ?, ?, ?, 0)";
char *err_msg = 0; char *err_msg = 0;
snprintf(buffer, PATH_MAX, "%s/email.sq3", conf.bbs_path);
rc = sqlite3_open(buffer, &db);
if (rc != SQLITE_OK) {
dolog("Cannot open database: %s", sqlite3_errmsg(db));
return;
}
sqlite3_busy_timeout(db, 5000);
rc = sqlite3_exec(db, csql, 0, 0, &err_msg);
if (rc != SQLITE_OK ) {
dolog("SQL error: %s", err_msg);
sqlite3_free(err_msg);
sqlite3_close(db);
return;
}
rc = sqlite3_prepare_v2(db, isql, -1, &res, 0);
if (rc == SQLITE_OK) {
sqlite3_bind_text(res, 1, gUser->loginname, -1, 0);
sqlite3_bind_text(res, 2, recipient, -1, 0);
sqlite3_bind_text(res, 3, subject, -1, 0);
sqlite3_bind_text(res, 4, msg, -1, 0);
sqlite3_bind_int(res, 5, time(NULL));
} else {
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
sqlite3_finalize(res);
sqlite3_close(db);
return;
}
sqlite3_step(res);
sqlite3_finalize(res);
sqlite3_close(db);
}
void send_email(struct user_record *user) {
char buffer[26];
char *recipient;
char *subject;
char *msg;
s_printf(get_string(54)); s_printf(get_string(54));
s_readstring(buffer, 16); s_readstring(buffer, 16);
@ -62,48 +109,7 @@ void send_email(struct user_record *user) {
msg = external_editor(user, user->loginname, recipient, NULL, 0, NULL, subject, 1, 0); msg = external_editor(user, user->loginname, recipient, NULL, 0, NULL, subject, 1, 0);
if (msg != NULL) { if (msg != NULL) {
sprintf(buffer, "%s/email.sq3", conf.bbs_path); commit_email(recipient, subject, msg);
rc = sqlite3_open(buffer, &db);
if (rc != SQLITE_OK) {
dolog("Cannot open database: %s", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
sqlite3_busy_timeout(db, 5000);
rc = sqlite3_exec(db, csql, 0, 0, &err_msg);
if (rc != SQLITE_OK ) {
dolog("SQL error: %s", err_msg);
sqlite3_free(err_msg);
sqlite3_close(db);
return;
}
rc = sqlite3_prepare_v2(db, isql, -1, &res, 0);
if (rc == SQLITE_OK) {
sqlite3_bind_text(res, 1, user->loginname, -1, 0);
sqlite3_bind_text(res, 2, recipient, -1, 0);
sqlite3_bind_text(res, 3, subject, -1, 0);
sqlite3_bind_text(res, 4, msg, -1, 0);
sqlite3_bind_int(res, 5, time(NULL));
} else {
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
sqlite3_finalize(res);
sqlite3_close(db);
s_printf("\r\nNo such email\r\n");
return;
}
sqlite3_step(res);
sqlite3_finalize(res);
sqlite3_close(db);
free(msg); free(msg);
} }
free(subject); free(subject);

View File

@ -56,6 +56,7 @@
#define MENU_DISPTXTFILEPAUSE 46 #define MENU_DISPTXTFILEPAUSE 46
#define MENU_GENWWWURLS 47 #define MENU_GENWWWURLS 47
#define MENU_NLBROWSER 48 #define MENU_NLBROWSER 48
#define MENU_SENDFEEDBACK 49
extern struct bbs_config conf; extern struct bbs_config conf;
extern struct user_record *gUser; extern struct user_record *gUser;
@ -87,6 +88,7 @@ int menu_system(char *menufile) {
char c; char c;
int clearscreen = 0; int clearscreen = 0;
char confirm; char confirm;
char *msg;
dolog("%s is loading menu: %s", gUser->loginname, menufile); dolog("%s is loading menu: %s", gUser->loginname, menufile);
@ -221,6 +223,8 @@ int menu_system(char *menufile) {
menu[menu_items-1]->command = MENU_GENWWWURLS; menu[menu_items-1]->command = MENU_GENWWWURLS;
} else if (strncasecmp(&buffer[8], "NLBROWSER", 9) == 0) { } else if (strncasecmp(&buffer[8], "NLBROWSER", 9) == 0) {
menu[menu_items-1]->command = MENU_NLBROWSER; menu[menu_items-1]->command = MENU_NLBROWSER;
} else if (strncasecmp(&buffer[8], "SENDFEEDBACK", 12) == 0) {
menu[menu_items-1]->command = MENU_SENDFEEDBACK;
} }
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) { } else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
menu[menu_items-1]->seclevel = atoi(&buffer[9]); menu[menu_items-1]->seclevel = atoi(&buffer[9]);
@ -564,6 +568,16 @@ int menu_system(char *menufile) {
case MENU_NLBROWSER: case MENU_NLBROWSER:
nl_browser(); nl_browser();
break; break;
case MENU_SENDFEEDBACK:
if (check_user(conf.sysop_name)) {
break;
}
msg = external_editor(gUser, conf.sysop_name, gUser->loginname, NULL, 0, NULL, "Feedback", 1, 0);
if (msg != NULL) {
commit_email(conf.sysop_name, "Feedback", msg);
free(msg);
}
break;
default: default:
break; break;
} }