summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c7
-rw-r--r--snac.h1
-rw-r--r--utils.c26
3 files changed, 33 insertions, 1 deletions
diff --git a/main.c b/main.c
index bce8198..003ad34 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,7 @@ int usage(void)
19 printf("init [{basedir}] Initializes the data storage\n"); 19 printf("init [{basedir}] Initializes the data storage\n");
20 printf("upgrade {basedir} Upgrade to a new version\n"); 20 printf("upgrade {basedir} Upgrade to a new version\n");
21 printf("adduser {basedir} [{uid}] Adds a new user\n"); 21 printf("adduser {basedir} [{uid}] Adds a new user\n");
22 printf("deluser {basedir} {uid} Deletes a user\n");
22 printf("httpd {basedir} Starts the HTTPD daemon\n"); 23 printf("httpd {basedir} Starts the HTTPD daemon\n");
23 printf("purge {basedir} Purges old data\n"); 24 printf("purge {basedir} Purges old data\n");
24 printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n"); 25 printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n");
@@ -169,7 +170,7 @@ int main(int argc, char *argv[])
169 } 170 }
170 171
171 if (!user_open(&snac, user)) { 172 if (!user_open(&snac, user)) {
172 printf("error in user '%s'\n", user); 173 printf("invalid user '%s'\n", user);
173 return 1; 174 return 1;
174 } 175 }
175 176
@@ -179,6 +180,10 @@ int main(int argc, char *argv[])
179 return resetpwd(&snac); 180 return resetpwd(&snac);
180 } 181 }
181 182
183 if (strcmp(cmd, "deluser") == 0) { /** **/
184 return deluser(&snac);
185 }
186
182 if (strcmp(cmd, "queue") == 0) { /** **/ 187 if (strcmp(cmd, "queue") == 0) { /** **/
183 process_user_queue(&snac); 188 process_user_queue(&snac);
184 return 0; 189 return 0;
diff --git a/snac.h b/snac.h
index 4d103d1..ed0f94d 100644
--- a/snac.h
+++ b/snac.h
@@ -276,6 +276,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
276int snac_init(const char *_basedir); 276int snac_init(const char *_basedir);
277int adduser(const char *uid); 277int adduser(const char *uid);
278int resetpwd(snac *snac); 278int resetpwd(snac *snac);
279int deluser(snac *user);
279 280
280extern const char *snac_blurb; 281extern const char *snac_blurb;
281 282
diff --git a/utils.c b/utils.c
index 21922d1..74058aa 100644
--- a/utils.c
+++ b/utils.c
@@ -337,3 +337,29 @@ int resetpwd(snac *snac)
337 337
338 return ret; 338 return ret;
339} 339}
340
341
342int deluser(snac *user)
343/* deletes a user */
344{
345 int ret = 0;
346 xs *fwers = following_list(user);
347 xs_list *p = fwers;
348 xs_str *v;
349
350 while (xs_list_iter(&p, &v)) {
351 xs *object = NULL;
352
353 if (valid_status(following_get(user, v, &object))) {
354 xs *msg = msg_undo(user, xs_dict_get(object, "object"));
355
356 following_del(user, v);
357
358 enqueue_output_by_actor(user, msg, v, 0);
359
360 printf("Unfollowing actor %s\n", v);
361 }
362 }
363
364 return ret;
365}