#include <sys/stat.h>
#include <sys/types.h>
#include <regex.h>
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "serv_extensions.h"
#include "file_ops.h"
#include "config.h"
#include "control.h"
-#include "tools.h"
-#include "mime_parser.h"
#include "html.h"
#include "genstamp.h"
#include "internet_addressing.h"
-#include "vcard.h"
#include "euidindex.h"
#include "journaling.h"
#include "citadel_dirs.h"
*choose_preferred, *fixed_output_pre,
*fixed_output_post, (void *)&ma, 0);
mime_parser(mptr, NULL,
- *output_preferred, NULL, NULL, (void *)&ma, 0);
+ *output_preferred, NULL, NULL, (void *)&ma, CC->msg4_dont_decode);
}
else {
ma.use_fo_hooks = 1;
*/
void cmd_msgp(char *cmdbuf)
{
- safestrncpy(CC->preferred_formats, cmdbuf,
- sizeof(CC->preferred_formats));
- cprintf("%d ok\n", CIT_OK);
+ if (!strcasecmp(cmdbuf, "dont_decode")) {
+ CC->msg4_dont_decode = 1;
+ cprintf("%d MSG4 will not pre-decode messages.\n", CIT_OK);
+ }
+ else {
+ safestrncpy(CC->preferred_formats, cmdbuf, sizeof(CC->preferred_formats));
+ cprintf("%d Preferred MIME formats have been set.\n", CIT_OK);
+ }
}
* room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
* returns 0 on success.
*/
-int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n) {
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n, int PostPublic) {
int ra;
- if (!(CC->logged_in)) {
+ if (!(CC->logged_in) &&
+ (PostPublic == POST_LOGGED_IN)) {
snprintf(errmsgbuf, n, "Not logged in.");
return (ERROR + NOT_LOGGED_IN);
}
+ else if (PostPublic == CHECK_EXISTANCE) {
+ return (0);
+ }
+ else if (!(CC->logged_in)) {
+ if ((CC->room.QRflags & QR_READONLY)) {
+ snprintf(errmsgbuf, n, "Not logged in.");
+ return (ERROR + NOT_LOGGED_IN);
+ }
+ else if (CC->room.QRflags2 & QR2_SUBSONLY){
+ ////TODO: check if we're in that list...
+ return (0);
+ }
+ else if (CC->room.QRflags2 & QR2_MODERATED) {
+ return (0);
+ }
+
+ }
if ((CC->user.axlevel < 2)
&& ((CC->room.QRflags & QR_MAILBOX) == 0)) {
int invalid;
struct ctdluser tempUS;
struct ctdlroom tempQR;
+ struct ctdlroom tempQR2;
+ int err = 0;
+ char errmsg[SIZ];
int in_quotes = 0;
/* Initialize */
}
else if ( (!strncasecmp(this_recp, "room_", 5))
&& (!getroom(&tempQR, &this_recp_cooked[5])) ) {
- ++ret->num_room;
- if (!IsEmptyStr(ret->recp_room)) {
- strcat(ret->recp_room, "|");
+
+ /* Save room so we can restore it later */
+ tempQR2 = CC->room;
+ CC->room = tempQR;
+
+ /* Check permissions to send mail to this room */
+ err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, POST_EXTERNAL);
+ //// TODO: CHECK_EXISTANCE for dict_tcp
+ if (err)
+ {
+ cprintf("%d %s\n", err, errmsg);
+ ++ret->num_error;
+ invalid = 1;
+ }
+ else {
+ ++ret->num_room;
+ if (!IsEmptyStr(ret->recp_room)) {
+ strcat(ret->recp_room, "|");
+ }
+ strcat(ret->recp_room, &this_recp_cooked[5]);
}
- strcat(ret->recp_room, &this_recp_cooked[5]);
+
+ /* Restore room in case something needs it */
+ CC->room = tempQR2;
+
}
else {
++ret->num_error;
/* first check to make sure the request is valid. */
- err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg);
+ err = CtdlDoIHavePermissionToPostInThisRoom(errmsg, sizeof errmsg, POST_LOGGED_IN);
if (err)
{
cprintf("%d %s\n", err, errmsg);
CtdlEncodeBase64(
&encoded_message[strlen(encoded_message)],
raw_message,
- (int)raw_length
+ (int)raw_length,
+ 0
);
}
else {