* and modern vNote format notes) and does its best to learn the subject (summary)
* and EUID (uid) of the note for Citadel's own nefarious purposes.
*/
-int serv_notes_beforesave(struct CtdlMessage *msg)
+int serv_notes_beforesave(struct CtdlMessage *msg, recptypes *recp)
{
char *p;
int a, i;
* any existing message containing that UUID.
*/
strcpy(uuid, "");
- p = msg->cm_fields['M'];
+ p = msg->cm_fields[eMesageText];
a = strlen(p);
while (--a > 0) {
if (!strncasecmp(p, "X-KOrg-Note-Id: ", 16)) { /* Found it */
syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
if (!IsEmptyStr(uuid)) {
+ CM_SetField(msg, eExclusiveID, uuid, strlen(uuid));
- if (msg->cm_fields['E'] != NULL) {
- free(msg->cm_fields['E']);
- }
- msg->cm_fields['E'] = strdup(uuid);
-
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
- }
- msg->cm_fields['U'] = strdup(uuid);
+ CM_CopyField(msg, eMsgSubject, eExclusiveID);
}
}
p++;
/* Modern clients are using vNote format. Check for one... */
- mime_parser(msg->cm_fields['M'],
+ mime_parser(msg->cm_fields[eMesageText],
NULL,
*notes_extract_vnote,
NULL, NULL,
/* Set the message EUID to the vNote UID */
- if (v->uid) if (!IsEmptyStr(v->uid)) {
+ if ((v->uid) && (!IsEmptyStr(v->uid))) {
syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid);
- if (msg->cm_fields['E'] != NULL) {
- free(msg->cm_fields['E']);
- }
- msg->cm_fields['E'] = strdup(v->uid);
+ CM_SetField(msg, eExclusiveID, v->uid, strlen(v->uid));
}
/* Set the message Subject to the vNote Summary */
- if (v->summary) if (!IsEmptyStr(v->summary)) {
- if (msg->cm_fields['U'] != NULL) {
- free(msg->cm_fields['U']);
- }
- msg->cm_fields['U'] = strdup(v->summary);
- if (strlen(msg->cm_fields['U']) > 72) {
- strcpy(&msg->cm_fields['U'][68], "...");
+ if ((v->summary) && (!IsEmptyStr(v->summary))) {
+ CM_SetField(msg, eMsgSubject, v->summary, strlen(v->summary));
+
+ if (strlen(msg->cm_fields[eMsgSubject]) > 72) {
+ strcpy(&msg->cm_fields[eMsgSubject][68], "...");
+ CM_CutFieldAt(msg, eMsgSubject, 72);
}
}