summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-09-20 10:47:14 +0200
committerGravatar default2024-09-20 10:47:14 +0200
commit2d2a685ec8bb30452fbf66025391f34f2bd03685 (patch)
tree0da1501b7a71e4ca13dd24ceb744b9bf569e94cf
parentMove migration work. (diff)
downloadsnac2-2d2a685ec8bb30452fbf66025391f34f2bd03685.tar.gz
snac2-2d2a685ec8bb30452fbf66025391f34f2bd03685.tar.xz
snac2-2d2a685ec8bb30452fbf66025391f34f2bd03685.zip
More migration work.
-rw-r--r--activitypub.c8
-rw-r--r--main.c16
-rw-r--r--xs.h6
-rw-r--r--xs_mime.h6
-rw-r--r--xs_set.h2
-rw-r--r--xs_unicode.h2
-rw-r--r--xs_version.h2
7 files changed, 29 insertions, 13 deletions
diff --git a/activitypub.c b/activitypub.c
index 9a49ba9..748327b 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -2696,6 +2696,14 @@ int migrate_account(snac *user)
2696 return 1; 2696 return 1;
2697 } 2697 }
2698 2698
2699 xs *move = msg_move(user, new_account);
2700 xs *fwers = follower_list(user);
2701
2702 xs_json_dump(move, 4, stdout);
2703 printf("\n");
2704 xs_json_dump(fwers, 4, stdout);
2705 printf("\n");
2706
2699 return 0; 2707 return 0;
2700} 2708}
2701 2709
diff --git a/main.c b/main.c
index 52659fc..3c7ccb1 100644
--- a/main.c
+++ b/main.c
@@ -47,8 +47,8 @@ int usage(void)
47 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n"); 47 printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
48 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n"); 48 printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
49 printf("search {basedir} {uid} {regex} Searches posts by content\n"); 49 printf("search {basedir} {uid} {regex} Searches posts by content\n");
50 printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n");
51 printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n"); 50 printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n");
51 printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n");
52 printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n"); 52 printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n");
53 53
54 return 1; 54 return 1;
@@ -292,12 +292,20 @@ int main(int argc, char *argv[])
292 status = webfinger_request(url, &actor, &uid); 292 status = webfinger_request(url, &actor, &uid);
293 293
294 if (valid_status(status)) { 294 if (valid_status(status)) {
295 snac.config = xs_dict_set(snac.config, "alias", actor); 295 if (strcmp(actor, snac.actor) == 0) {
296 snac_log(&snac, xs_fmt("You can't be your own alias"));
297 return 1;
298 }
299 else {
300 snac.config = xs_dict_set(snac.config, "alias", actor);
296 301
297 user_persist(&snac, 1); 302 user_persist(&snac, 1);
303 }
298 } 304 }
299 else 305 else {
300 snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status)); 306 snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status));
307 return 1;
308 }
301 309
302 return 0; 310 return 0;
303 } 311 }
diff --git a/xs.h b/xs.h
index 9c12c4a..e5269a4 100644
--- a/xs.h
+++ b/xs.h
@@ -23,7 +23,6 @@ typedef enum {
23 XSTYPE_LITEM = 0x1f, /* Element of a list (any type) */ 23 XSTYPE_LITEM = 0x1f, /* Element of a list (any type) */
24 XSTYPE_DICT = 0x1c, /* Sequence of KEYVALs up to EOM (with size) */ 24 XSTYPE_DICT = 0x1c, /* Sequence of KEYVALs up to EOM (with size) */
25 XSTYPE_KEYVAL = 0x1e, /* key + value (STRING key + any type) */ 25 XSTYPE_KEYVAL = 0x1e, /* key + value (STRING key + any type) */
26 XSTYPE_EOM = 0x19, /* End of Multiple (LIST or DICT) */
27 XSTYPE_DATA = 0x10 /* A block of anonymous data */ 26 XSTYPE_DATA = 0x10 /* A block of anonymous data */
28} xstype; 27} xstype;
29 28
@@ -170,7 +169,7 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char
170 xs_val *ndata = realloc(ptr, size); 169 xs_val *ndata = realloc(ptr, size);
171 170
172 if (ndata == NULL) { 171 if (ndata == NULL) {
173 fprintf(stderr, "**OUT OF MEMORY**\n"); 172 fprintf(stderr, "ERROR: out of memory at %s:%d: %s()\n", file, line, func);
174 abort(); 173 abort();
175 } 174 }
176 175
@@ -266,7 +265,6 @@ xstype xs_type(const xs_val *data)
266 case XSTYPE_DICT: 265 case XSTYPE_DICT:
267 case XSTYPE_KEYVAL: 266 case XSTYPE_KEYVAL:
268 case XSTYPE_NUMBER: 267 case XSTYPE_NUMBER:
269 case XSTYPE_EOM:
270 case XSTYPE_DATA: 268 case XSTYPE_DATA:
271 t = data[0]; 269 t = data[0];
272 break; 270 break;
@@ -696,7 +694,7 @@ xs_list *xs_list_new(void)
696{ 694{
697 int sz = 1 + _XS_TYPE_SIZE + 1; 695 int sz = 1 + _XS_TYPE_SIZE + 1;
698 xs_list *l = xs_realloc(NULL, sz); 696 xs_list *l = xs_realloc(NULL, sz);
699 memset(l, XSTYPE_EOM, sz); 697 memset(l, '\0', sz);
700 698
701 l[0] = XSTYPE_LIST; 699 l[0] = XSTYPE_LIST;
702 _xs_put_size(l, sz); 700 _xs_put_size(l, sz);
diff --git a/xs_mime.h b/xs_mime.h
index 853b092..b016490 100644
--- a/xs_mime.h
+++ b/xs_mime.h
@@ -1,8 +1,8 @@
1/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */ 1/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */
2 2
3#ifndef _XS_MIME 3#ifndef _XS_MIME_H
4 4
5#define _XS_MIME 5#define _XS_MIME_H
6 6
7const char *xs_mime_by_ext(const char *file); 7const char *xs_mime_by_ext(const char *file);
8 8
@@ -81,4 +81,4 @@ const char *xs_mime_by_ext(const char *file)
81 81
82#endif /* XS_IMPLEMENTATION */ 82#endif /* XS_IMPLEMENTATION */
83 83
84#endif /* XS_MIME */ 84#endif /* XS_MIME_H */
diff --git a/xs_set.h b/xs_set.h
index 94c2b84..f6b65aa 100644
--- a/xs_set.h
+++ b/xs_set.h
@@ -47,7 +47,7 @@ xs_list *xs_set_result(xs_set *s)
47void xs_set_free(xs_set *s) 47void xs_set_free(xs_set *s)
48/* frees a set, dropping the list */ 48/* frees a set, dropping the list */
49{ 49{
50 free(xs_set_result(s)); 50 xs_free(xs_set_result(s));
51} 51}
52 52
53 53
diff --git a/xs_unicode.h b/xs_unicode.h
index a5a1dcb..9663190 100644
--- a/xs_unicode.h
+++ b/xs_unicode.h
@@ -33,6 +33,8 @@
33 33
34#ifdef XS_IMPLEMENTATION 34#ifdef XS_IMPLEMENTATION
35 35
36#include <ctype.h>
37
36#ifndef xs_countof 38#ifndef xs_countof
37#define xs_countof(a) (sizeof((a)) / sizeof((*a))) 39#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
38#endif 40#endif
diff --git a/xs_version.h b/xs_version.h
index 8697701..13aa7c6 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* 9c3dd1b1165c25baa154e82d8d278926e376af81 2024-09-14T18:18:42+02:00 */ /* ae3126a2d093c6bb5c36328e27bc93a452aff379 2024-09-20T07:39:32+02:00 */