]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/modules/migrate/serv_migrate.c
remove extra msgs
[citadel.git] / citadel / server / modules / migrate / serv_migrate.c
index a45cc017da4a6c06be0e86441b1e10e7e717e807..3a58bac6379baf3915f2fe284fc1abe4b4d905e1 100644 (file)
@@ -1,6 +1,6 @@
 // This module dumps and/or loads the Citadel database in XML format.
 //
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 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.
@@ -15,7 +15,7 @@
 // 0%          started
 // 2%          finished exporting configuration
 // 7%          finished exporting users
-// 12%         finished exporting openids
+// 12%
 // 17%         finished exporting rooms
 // 18%         finished exporting floors
 // 25%         finished exporting visits
@@ -40,7 +40,7 @@
 #include <limits.h>
 #include <expat.h>
 #include <libcitadel.h>
-#include "../../citadel.h"
+#include "../../citadel_defs.h"
 #include "../../server.h"
 #include "../../citserver.h"
 #include "../../support.h"
@@ -49,6 +49,7 @@
 #include "../../msgbase.h"
 #include "../../user_ops.h"
 #include "../../euidindex.h"
+#include "../../internet_addressing.h"
 #include "../../ctdl_module.h"
 
 char migr_tempfilename1[PATH_MAX];
@@ -107,8 +108,6 @@ void migr_export_users_backend(char *username, void *data) {
        cprintf("<u_uid>%ld</u_uid>\n", (long)u.uid);
        client_write(HKEY("<u_password>"));     xml_strout(u.password);         client_write(HKEY("</u_password>\n"));
        cprintf("<u_flags>%u</u_flags>\n", u.flags);
-       cprintf("<u_timescalled>%ld</u_timescalled>\n", u.timescalled);
-       cprintf("<u_posted>%ld</u_posted>\n", u.posted);
        cprintf("<u_axlevel>%d</u_axlevel>\n", u.axlevel);
        cprintf("<u_usernum>%ld</u_usernum>\n", u.usernum);
        cprintf("<u_lastcall>%ld</u_lastcall>\n", (long)u.lastcall);
@@ -252,16 +251,16 @@ int is_sequence_set(char *s) {
 
 // Traverse the visits file...
 void migr_export_visits(void) {
-       visit vbuf;
+       struct visit vbuf;
        struct cdbdata *cdbv;
 
        cdb_rewind(CDB_VISIT);
 
        while (cdbv = cdb_next_item(CDB_VISIT), cdbv != NULL) {
-               memset(&vbuf, 0, sizeof(visit));
+               memset(&vbuf, 0, sizeof(struct visit));
                memcpy(&vbuf, cdbv->ptr,
-                      ((cdbv->len > sizeof(visit)) ?
-                       sizeof(visit) : cdbv->len));
+                      ((cdbv->len > sizeof(struct visit)) ?
+                       sizeof(struct visit) : cdbv->len));
                cdb_free(cdbv);
 
                client_write(HKEY("<visit>\n"));
@@ -366,28 +365,6 @@ void migr_export_message(long msgnum) {
 }
 
 
-void migr_export_openids(void) {
-       struct cdbdata *cdboi;
-       long usernum;
-       char url[512];
-
-       cdb_rewind(CDB_EXTAUTH);
-       while (cdboi = cdb_next_item(CDB_EXTAUTH), cdboi != NULL) {
-               if (cdboi->len > sizeof(long)) {
-                       client_write(HKEY("<openid>\n"));
-                       memcpy(&usernum, cdboi->ptr, sizeof(long));
-                       snprintf(url, sizeof url, "%s", (cdboi->ptr)+sizeof(long) );
-                       client_write(HKEY("<oid_url>"));
-                       xml_strout(url);
-                       client_write(HKEY("</oid_url>\n"));
-                       cprintf("<oid_usernum>%ld</oid_usernum>\n", usernum);
-                       client_write(HKEY("</openid>\n"));
-               }
-               cdb_free(cdboi);
-       }
-}
-
-
 void migr_export_configs(void) {
        struct cdbdata *cdbcfg;
        int keylen = 0;
@@ -467,7 +444,6 @@ void migr_do_export(void) {
        
        if (Ctx->kill_me == 0)  migr_export_users();
        cprintf("<progress>%d</progress>\n", 7);
-       if (Ctx->kill_me == 0)  migr_export_openids();
        cprintf("<progress>%d</progress>\n", 12);
        if (Ctx->kill_me == 0)  migr_export_rooms();
        cprintf("<progress>%d</progress>\n", 17);
@@ -495,12 +471,10 @@ StrBuf *migr_chardata = NULL;
 StrBuf *migr_MsgData = NULL;
 struct ctdluser usbuf;
 struct ctdlroom qrbuf;
-char openid_url[512];
-long openid_usernum = 0;
 char FRname[ROOMNAMELEN];
 struct floor flbuf;
 int floornum = 0;
-visit vbuf;
+struct visit vbuf;
 struct MetaData smi;
 long import_msgnum = 0;
 
@@ -540,12 +514,11 @@ void migr_xml_start(void *data, const char *el, const char **attr) {
 
        // When we begin receiving XML for one of these record types, clear out the associated
        // buffer so we don't accidentally carry over any data from a previous record.
-       if (!strcasecmp(el, "user"))                    memset(&usbuf, 0, sizeof (struct ctdluser));
-       else if (!strcasecmp(el, "openid"))             memset(openid_url, 0, sizeof openid_url);
-       else if (!strcasecmp(el, "room"))               memset(&qrbuf, 0, sizeof (struct ctdlroom));
+       if (!strcasecmp(el, "user"))                    memset(&usbuf, 0, sizeof(struct ctdluser));
+       else if (!strcasecmp(el, "room"))               memset(&qrbuf, 0, sizeof(struct ctdlroom));
        else if (!strcasecmp(el, "room_messages"))      memset(FRname, 0, sizeof FRname);
-       else if (!strcasecmp(el, "floor"))              memset(&flbuf, 0, sizeof (struct floor));
-       else if (!strcasecmp(el, "visit"))              memset(&vbuf, 0, sizeof (visit));
+       else if (!strcasecmp(el, "floor"))              memset(&flbuf, 0, sizeof(struct floor));
+       else if (!strcasecmp(el, "visit"))              memset(&vbuf, 0, sizeof(struct visit));
 
        else if (!strcasecmp(el, "message")) {
                memset(&smi, 0, sizeof (struct MetaData));
@@ -572,8 +545,6 @@ int migr_userrecord(void *data, const char *el) {
        else if (!strcasecmp(el, "u_uid"))                      usbuf.uid = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "u_password"))                 safestrncpy(usbuf.password, ChrPtr(migr_chardata), sizeof usbuf.password);
        else if (!strcasecmp(el, "u_flags"))                    usbuf.flags = atoi(ChrPtr(migr_chardata));
-       else if (!strcasecmp(el, "u_timescalled"))              usbuf.timescalled = atol(ChrPtr(migr_chardata));
-       else if (!strcasecmp(el, "u_posted"))                   usbuf.posted = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "u_axlevel"))                  usbuf.axlevel = atoi(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "u_usernum"))                  usbuf.usernum = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "u_lastcall"))                 usbuf.lastcall = atol(ChrPtr(migr_chardata));
@@ -695,23 +666,6 @@ void migr_xml_end(void *data, const char *el) {
                syslog(LOG_INFO, "migrate: imported user: %s", usbuf.fullname);
        }
 
-       // *** OPENID ***
-
-       else if (!strcasecmp(el, "oid_url"))                    safestrncpy(openid_url, ChrPtr(migr_chardata), sizeof openid_url);
-       else if (!strcasecmp(el, "oid_usernum"))                openid_usernum = atol(ChrPtr(migr_chardata));
-
-       else if (!strcasecmp(el, "openid")) {                   // see serv_openid_rp.c for a description of the record format
-               char *oid_data;
-               int oid_data_len;
-               oid_data_len = sizeof(long) + strlen(openid_url) + 1;
-               oid_data = malloc(oid_data_len);
-               memcpy(oid_data, &openid_usernum, sizeof(long));
-               memcpy(&oid_data[sizeof(long)], openid_url, strlen(openid_url) + 1);
-               cdb_store(CDB_EXTAUTH, openid_url, strlen(openid_url), oid_data, oid_data_len);
-               free(oid_data);
-               syslog(LOG_INFO, "migrate: imported OpenID: %s (%ld)", openid_url, openid_usernum);
-       }
-
        // *** ROOM ***
        else if ((!strncasecmp(el, HKEY("QR"))) && 
                 migr_roomrecord(data, el))
@@ -868,6 +822,7 @@ void migr_do_import(void) {
        rebuild_euid_index();
        rebuild_usersbynumber();
        CtdlSetConfigInt("MM_fulltext_wordbreaker", -1);        // Set an invalid wordbreaker to force re-indexing
+       CtdlRebuildDirectoryIndex();                            // Force a rebuild of the directory index
        CC->dont_term = 0;
 }
 
@@ -935,7 +890,7 @@ int migr_restore_message_metadata(long msgnum, int refcount) {
        if (mptr != NULL) {
                char *aptr;
                safestrncpy(smi.meta_content_type, &mptr[13], sizeof smi.meta_content_type);
-               striplt(smi.meta_content_type);
+               string_trim(smi.meta_content_type);
                aptr = smi.meta_content_type;
                while (!IsEmptyStr(aptr)) {
                        if ((*aptr == ';')