summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorLouis Brauer <louis77@noreply.codeberg.org>2024-05-25 08:05:36 +0000
committerLouis Brauer <louis77@noreply.codeberg.org>2024-05-25 08:05:36 +0000
commit84a767dd0878013194ed7551b5ae6ef715e841a6 (patch)
tree9fb1b2b89e0bfbb4b8bf1e85d840c8653e646bb7 /main.c
parentcf5718bf4dedb85d2e1a1495f05bfc7e66124022 (diff)
parenta2920800007c291bdf2b5264622cbc713d4961ee (diff)
Merge pull request 'master' (#1) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/louis77/snac2/pulls/1
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/main.c b/main.c
index 06cae78..c88eebe 100644
--- a/main.c
+++ b/main.c
@@ -44,6 +44,7 @@ int usage(void)
printf("limit {basedir} {uid} {actor} Limits an actor (drops their announces)\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("search {basedir} {uid} {regex} Searches posts by content\n");
return 1;
}
@@ -314,7 +315,7 @@ int main(int argc, char *argv[])
xs *msg = msg_follow(&snac, url);
if (msg != NULL) {
- char *actor = xs_dict_get(msg, "object");
+ const char *actor = xs_dict_get(msg, "object");
following_add(&snac, actor, msg);
@@ -374,6 +375,23 @@ int main(int argc, char *argv[])
return 0;
}
+ if (strcmp(cmd, "search") == 0) { /** **/
+ int to;
+
+ /* 'url' contains the regex */
+ xs *r = content_search(&snac, url, 1, 0, XS_ALL, 10, &to);
+
+ int c = 0;
+ const char *v;
+
+ /* print results as standalone links */
+ while (xs_list_next(r, &v, &c)) {
+ printf("%s/admin/p/%s\n", snac.actor, v);
+ }
+
+ return 0;
+ }
+
if (strcmp(cmd, "ping") == 0) { /** **/
xs *actor_o = NULL;
@@ -458,6 +476,12 @@ int main(int argc, char *argv[])
return 0;
}
+ if (strcmp(cmd, "request2") == 0) { /** **/
+ enqueue_object_request(&snac, url, 2);
+
+ return 0;
+ }
+
if (strcmp(cmd, "actor") == 0) { /** **/
int status;
xs *data = NULL;