mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New function webfinger_request_signed().
This commit is contained in:
parent
e26d05746c
commit
e0c6fb786c
3 changed files with 47 additions and 17 deletions
49
main.c
49
main.c
|
@ -16,20 +16,21 @@ int usage(void)
|
|||
printf("\n");
|
||||
printf("Commands:\n");
|
||||
printf("\n");
|
||||
printf("init [{basedir}] Initializes the data storage\n");
|
||||
printf("upgrade {basedir} Upgrade to a new version\n");
|
||||
printf("adduser {basedir} [{uid}] Adds a new user\n");
|
||||
printf("httpd {basedir} Starts the HTTPD daemon\n");
|
||||
printf("purge {basedir} Purges old data\n");
|
||||
printf("webfinger {basedir} {user} Queries about a @user@host or actor\n");
|
||||
printf("queue {basedir} {uid} Processes a user queue\n");
|
||||
printf("follow {basedir} {uid} {actor} Follows an actor\n");
|
||||
printf("unfollow {basedir} {uid} {actor} Unfollows an actor\n");
|
||||
printf("request {basedir} {uid} {url} Requests an object\n");
|
||||
printf("actor {basedir} {uid} {url} Requests an actor\n");
|
||||
printf("note {basedir} {uid} {'text'} Sends a note to followers\n");
|
||||
printf("resetpwd {basedir} {uid} Resets the password of a user\n");
|
||||
printf("ping {basedir} {uid} {actor} Pings an actor\n");
|
||||
printf("init [{basedir}] Initializes the data storage\n");
|
||||
printf("upgrade {basedir} Upgrade to a new version\n");
|
||||
printf("adduser {basedir} [{uid}] Adds a new user\n");
|
||||
printf("httpd {basedir} Starts the HTTPD daemon\n");
|
||||
printf("purge {basedir} Purges old data\n");
|
||||
printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n");
|
||||
printf("queue {basedir} {uid} Processes a user queue\n");
|
||||
printf("follow {basedir} {uid} {actor} Follows an actor\n");
|
||||
printf("unfollow {basedir} {uid} {actor} Unfollows an actor\n");
|
||||
printf("request {basedir} {uid} {url} Requests an object\n");
|
||||
printf("actor {basedir} {uid} {url} Requests an actor\n");
|
||||
printf("note {basedir} {uid} {'text'} Sends a note to followers\n");
|
||||
printf("resetpwd {basedir} {uid} Resets the password of a user\n");
|
||||
printf("ping {basedir} {uid} {actor} Pings an actor\n");
|
||||
printf("webfinger_s {basedir} {uid} {actor} Queries about an actor (@user@host or actor url)\n");
|
||||
/* printf("question {basedir} {uid} 'opts' Generates a poll (;-separated opts)\n");*/
|
||||
|
||||
return 1;
|
||||
|
@ -179,6 +180,22 @@ int main(int argc, char *argv[])
|
|||
if ((url = GET_ARGV()) == NULL)
|
||||
return usage();
|
||||
|
||||
if (strcmp(cmd, "webfinger_s") == 0) { /** **/
|
||||
xs *actor = NULL;
|
||||
xs *uid = NULL;
|
||||
int status;
|
||||
|
||||
status = webfinger_request_signed(&snac, url, &actor, &uid);
|
||||
|
||||
printf("status: %d\n", status);
|
||||
if (actor != NULL)
|
||||
printf("actor: %s\n", actor);
|
||||
if (uid != NULL)
|
||||
printf("uid: %s\n", uid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(cmd, "announce") == 0) { /** **/
|
||||
xs *msg = msg_admiration(&snac, url, "Announce");
|
||||
|
||||
|
@ -352,5 +369,7 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fprintf(stderr, "ERROR: bad command '%s'\n", cmd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
1
snac.h
1
snac.h
|
@ -191,6 +191,7 @@ int check_signature(snac *snac, xs_dict *req, xs_str **err);
|
|||
|
||||
void httpd(void);
|
||||
|
||||
int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user);
|
||||
int webfinger_request(const char *qs, char **actor, char **user);
|
||||
int webfinger_get_handler(xs_dict *req, char *q_path,
|
||||
char **body, int *b_size, char **ctype);
|
||||
|
|
14
webfinger.c
14
webfinger.c
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "snac.h"
|
||||
|
||||
int webfinger_request(const char *qs, char **actor, char **user)
|
||||
int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user)
|
||||
/* queries the webfinger for qs and fills the required fields */
|
||||
{
|
||||
int status;
|
||||
|
@ -61,7 +61,10 @@ int webfinger_request(const char *qs, char **actor, char **user)
|
|||
else {
|
||||
xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource);
|
||||
|
||||
xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
|
||||
if (snac == NULL)
|
||||
xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
|
||||
else
|
||||
http_signed_request(snac, "GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
|
||||
}
|
||||
|
||||
if (valid_status(status)) {
|
||||
|
@ -96,6 +99,13 @@ int webfinger_request(const char *qs, char **actor, char **user)
|
|||
}
|
||||
|
||||
|
||||
int webfinger_request(const char *qs, char **actor, char **user)
|
||||
/* queries the webfinger for qs and fills the required fields */
|
||||
{
|
||||
return webfinger_request_signed(NULL, qs, actor, user);
|
||||
}
|
||||
|
||||
|
||||
int webfinger_get_handler(d_char *req, char *q_path,
|
||||
char **body, int *b_size, char **ctype)
|
||||
/* serves webfinger queries */
|
||||
|
|
Loading…
Reference in a new issue