/*
* Server-side module for Wiki rooms. This handles things like version control.
*
- * Copyright (c) 2009-2015 by the citadel.org team
+ * Copyright (c) 2009-2020 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
char *diffbuf = NULL;
size_t diffbuf_len = 0;
char *ptr = NULL;
+ long newmsgid;
+ StrBuf *msgidbuf;
if (!CCC->logged_in) return(0); /* Only do this if logged in. */
/* If there's no EUID we can't do this. Reject the post. */
if (CM_IsEmpty(msg, eExclusiveID)) return(1);
+ newmsgid = get_new_message_number();
+ msgidbuf = NewStrBuf();
+ StrBufPrintf(msgidbuf, "%08lX-%08lX@%s/%s",
+ (long unsigned int) time(NULL),
+ (long unsigned int) newmsgid,
+ CtdlGetConfigStr("c_fqdn"),
+ msg->cm_fields[eExclusiveID]
+ );
+
+ CM_SetAsFieldSB(msg, emessageId, &msgidbuf);
+
history_page_len = snprintf(history_page, sizeof history_page,
"%s_HISTORY_", msg->cm_fields[eExclusiveID]);
/* See if we can retrieve the previous version. */
old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields[eExclusiveID], &CCC->room);
if (old_msgnum > 0L) {
- old_msg = CtdlFetchMessage(old_msgnum, 1, 1);
+ old_msg = CtdlFetchMessage(old_msgnum, 1);
}
else {
old_msg = NULL;
history_msgnum = CtdlLocateMessageByEuid(history_page, &CCC->room);
history_msg = NULL;
if (history_msgnum > 0L) {
- history_msg = CtdlFetchMessage(history_msgnum, 1, 1);
+ history_msg = CtdlFetchMessage(history_msgnum, 1);
}
/* Create a new history message if necessary */
CM_SetFieldLONG(history_msg, eTimestamp, Now);
- CtdlSubmitMsg(history_msg, NULL, "", 0);
+ CtdlSubmitMsg(history_msg, NULL, "");
}
else {
syslog(LOG_ALERT, "Empty boundary string in history message. No history!\n");
snprintf(history_page_name, sizeof history_page_name, "%s_HISTORY_", pagename);
msgnum = CtdlLocateMessageByEuid(history_page_name, &CC->room);
if (msgnum > 0L) {
- msg = CtdlFetchMessage(msgnum, 1, 1);
+ msg = CtdlFetchMessage(msgnum, 1);
}
else {
msg = NULL;
*/
msgnum = CtdlLocateMessageByEuid(pagename, &CCC->room);
if (msgnum > 0L) {
- msg = CtdlFetchMessage(msgnum, 1, 1);
+ msg = CtdlFetchMessage(msgnum, 1);
}
else {
msg = NULL;
fclose(fp);
}
else {
- syslog(LOG_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
+ syslog(LOG_ERR, "%s: %m", temp);
}
CM_Free(msg);
snprintf(history_page_name, sizeof history_page_name, "%s_HISTORY_", pagename);
msgnum = CtdlLocateMessageByEuid(history_page_name, &CCC->room);
if (msgnum > 0L) {
- msg = CtdlFetchMessage(msgnum, 1, 1);
+ msg = CtdlFetchMessage(msgnum, 1);
}
else {
msg = NULL;
else if (!strcasecmp(operation, "fetch")) {
CM_SetField(msg, eAuthor, HKEY("Citadel"));
CtdlCreateRoom(wwm, 5, "", 0, 1, 1, VIEW_BBS); /* Not an error if already exists */
- msgnum = CtdlSubmitMsg(msg, NULL, wwm, 0); /* Store the revision here */
+ msgnum = CtdlSubmitMsg(msg, NULL, wwm); /* Store the revision here */
/*
* WARNING: VILE SLEAZY HACK
CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
}
- CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
-
if (!IsEmptyStr(pagename)) {
CM_SetField(msg, eExclusiveID, pagename, strlen(pagename));
}
- msgnum = CtdlSubmitMsg(msg, NULL, "", 0); /* Replace the current revision */
+ msgnum = CtdlSubmitMsg(msg, NULL, ""); /* Replace the current revision */
}
else {
/* Theoretically it is impossible to get here, but throw an error anyway */