mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-23 13:45:05 +00:00
More migration work.
This commit is contained in:
parent
3a5c78147c
commit
2d2a685ec8
7 changed files with 29 additions and 13 deletions
|
@ -2696,6 +2696,14 @@ int migrate_account(snac *user)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xs *move = msg_move(user, new_account);
|
||||||
|
xs *fwers = follower_list(user);
|
||||||
|
|
||||||
|
xs_json_dump(move, 4, stdout);
|
||||||
|
printf("\n");
|
||||||
|
xs_json_dump(fwers, 4, stdout);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
main.c
16
main.c
|
@ -47,8 +47,8 @@ int usage(void)
|
||||||
printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
|
printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
|
||||||
printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
|
printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
|
||||||
printf("search {basedir} {uid} {regex} Searches posts by content\n");
|
printf("search {basedir} {uid} {regex} Searches posts by content\n");
|
||||||
printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n");
|
|
||||||
printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n");
|
printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n");
|
||||||
|
printf("alias {basedir} {uid} {account} Sets account (@user@host or actor url) as an alias\n");
|
||||||
printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n");
|
printf("migrate {basedir} {uid} Migrates to the account defined as the alias\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -292,12 +292,20 @@ int main(int argc, char *argv[])
|
||||||
status = webfinger_request(url, &actor, &uid);
|
status = webfinger_request(url, &actor, &uid);
|
||||||
|
|
||||||
if (valid_status(status)) {
|
if (valid_status(status)) {
|
||||||
snac.config = xs_dict_set(snac.config, "alias", actor);
|
if (strcmp(actor, snac.actor) == 0) {
|
||||||
|
snac_log(&snac, xs_fmt("You can't be your own alias"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snac.config = xs_dict_set(snac.config, "alias", actor);
|
||||||
|
|
||||||
user_persist(&snac, 1);
|
user_persist(&snac, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status));
|
snac_log(&snac, xs_fmt("Webfinger error for %s %d", url, status));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
6
xs.h
6
xs.h
|
@ -23,7 +23,6 @@ typedef enum {
|
||||||
XSTYPE_LITEM = 0x1f, /* Element of a list (any type) */
|
XSTYPE_LITEM = 0x1f, /* Element of a list (any type) */
|
||||||
XSTYPE_DICT = 0x1c, /* Sequence of KEYVALs up to EOM (with size) */
|
XSTYPE_DICT = 0x1c, /* Sequence of KEYVALs up to EOM (with size) */
|
||||||
XSTYPE_KEYVAL = 0x1e, /* key + value (STRING key + any type) */
|
XSTYPE_KEYVAL = 0x1e, /* key + value (STRING key + any type) */
|
||||||
XSTYPE_EOM = 0x19, /* End of Multiple (LIST or DICT) */
|
|
||||||
XSTYPE_DATA = 0x10 /* A block of anonymous data */
|
XSTYPE_DATA = 0x10 /* A block of anonymous data */
|
||||||
} xstype;
|
} xstype;
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char
|
||||||
xs_val *ndata = realloc(ptr, size);
|
xs_val *ndata = realloc(ptr, size);
|
||||||
|
|
||||||
if (ndata == NULL) {
|
if (ndata == NULL) {
|
||||||
fprintf(stderr, "**OUT OF MEMORY**\n");
|
fprintf(stderr, "ERROR: out of memory at %s:%d: %s()\n", file, line, func);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +265,6 @@ xstype xs_type(const xs_val *data)
|
||||||
case XSTYPE_DICT:
|
case XSTYPE_DICT:
|
||||||
case XSTYPE_KEYVAL:
|
case XSTYPE_KEYVAL:
|
||||||
case XSTYPE_NUMBER:
|
case XSTYPE_NUMBER:
|
||||||
case XSTYPE_EOM:
|
|
||||||
case XSTYPE_DATA:
|
case XSTYPE_DATA:
|
||||||
t = data[0];
|
t = data[0];
|
||||||
break;
|
break;
|
||||||
|
@ -696,7 +694,7 @@ xs_list *xs_list_new(void)
|
||||||
{
|
{
|
||||||
int sz = 1 + _XS_TYPE_SIZE + 1;
|
int sz = 1 + _XS_TYPE_SIZE + 1;
|
||||||
xs_list *l = xs_realloc(NULL, sz);
|
xs_list *l = xs_realloc(NULL, sz);
|
||||||
memset(l, XSTYPE_EOM, sz);
|
memset(l, '\0', sz);
|
||||||
|
|
||||||
l[0] = XSTYPE_LIST;
|
l[0] = XSTYPE_LIST;
|
||||||
_xs_put_size(l, sz);
|
_xs_put_size(l, sz);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */
|
/* copyright (c) 2022 - 2024 grunfink et al. / MIT license */
|
||||||
|
|
||||||
#ifndef _XS_MIME
|
#ifndef _XS_MIME_H
|
||||||
|
|
||||||
#define _XS_MIME
|
#define _XS_MIME_H
|
||||||
|
|
||||||
const char *xs_mime_by_ext(const char *file);
|
const char *xs_mime_by_ext(const char *file);
|
||||||
|
|
||||||
|
@ -81,4 +81,4 @@ const char *xs_mime_by_ext(const char *file)
|
||||||
|
|
||||||
#endif /* XS_IMPLEMENTATION */
|
#endif /* XS_IMPLEMENTATION */
|
||||||
|
|
||||||
#endif /* XS_MIME */
|
#endif /* XS_MIME_H */
|
||||||
|
|
2
xs_set.h
2
xs_set.h
|
@ -47,7 +47,7 @@ xs_list *xs_set_result(xs_set *s)
|
||||||
void xs_set_free(xs_set *s)
|
void xs_set_free(xs_set *s)
|
||||||
/* frees a set, dropping the list */
|
/* frees a set, dropping the list */
|
||||||
{
|
{
|
||||||
free(xs_set_result(s));
|
xs_free(xs_set_result(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#ifdef XS_IMPLEMENTATION
|
#ifdef XS_IMPLEMENTATION
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifndef xs_countof
|
#ifndef xs_countof
|
||||||
#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
|
#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* 9c3dd1b1165c25baa154e82d8d278926e376af81 2024-09-14T18:18:42+02:00 */
|
/* ae3126a2d093c6bb5c36328e27bc93a452aff379 2024-09-20T07:39:32+02:00 */
|
||||||
|
|
Loading…
Reference in a new issue