mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Fixed a bug in the digest header.
This commit is contained in:
parent
6169932733
commit
6f7f98ded3
4 changed files with 23 additions and 11 deletions
|
@ -233,8 +233,8 @@ void process_message(snac *snac, char *msg, char *req)
|
||||||
|
|
||||||
timeline_request(snac, in_reply_to);
|
timeline_request(snac, in_reply_to);
|
||||||
|
|
||||||
|
if (timeline_add(snac, id, msg, in_reply_to))
|
||||||
snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
|
snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
|
||||||
timeline_add(snac, id, msg, in_reply_to);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -247,8 +247,10 @@ void process_message(snac *snac, char *msg, char *req)
|
||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
if (strcmp(type, "Like") == 0) {
|
if (strcmp(type, "Like") == 0) {
|
||||||
if (xs_type(object) == XSTYPE_STRING)
|
if (xs_type(object) == XSTYPE_STRING) {
|
||||||
timeline_admire(snac, object, actor, 1);
|
timeline_admire(snac, object, actor, 1);
|
||||||
|
snac_log(snac, xs_fmt("new 'Like' %s %s", actor, object));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snac_debug(snac, 2, xs_fmt("xs_type for 'Like' object not string"));
|
snac_debug(snac, 2, xs_fmt("xs_type for 'Like' object not string"));
|
||||||
}
|
}
|
||||||
|
@ -258,6 +260,7 @@ void process_message(snac *snac, char *msg, char *req)
|
||||||
timeline_request(snac, object);
|
timeline_request(snac, object);
|
||||||
|
|
||||||
timeline_admire(snac, object, actor, 0);
|
timeline_admire(snac, object, actor, 0);
|
||||||
|
snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snac_debug(snac, 2, xs_fmt("xs_type for 'Announce' object not string"));
|
snac_debug(snac, 2, xs_fmt("xs_type for 'Announce' object not string"));
|
||||||
|
|
6
data.c
6
data.c
|
@ -530,14 +530,14 @@ void _timeline_write(snac *snac, char *id, char *msg, char *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void timeline_add(snac *snac, char *id, char *o_msg, char *parent)
|
int timeline_add(snac *snac, char *id, char *o_msg, char *parent)
|
||||||
/* adds a message to the timeline */
|
/* adds a message to the timeline */
|
||||||
{
|
{
|
||||||
xs *pfn = _timeline_find_fn(snac, id);
|
xs *pfn = _timeline_find_fn(snac, id);
|
||||||
|
|
||||||
if (pfn != NULL) {
|
if (pfn != NULL) {
|
||||||
snac_log(snac, xs_fmt("timeline_add refusing rewrite %s %s", id, pfn));
|
snac_log(snac, xs_fmt("timeline_add refusing rewrite %s %s", id, pfn));
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xs *msg = xs_dup(o_msg);
|
xs *msg = xs_dup(o_msg);
|
||||||
|
@ -560,6 +560,8 @@ void timeline_add(snac *snac, char *id, char *o_msg, char *parent)
|
||||||
_timeline_write(snac, id, msg, parent);
|
_timeline_write(snac, id, msg, parent);
|
||||||
|
|
||||||
snac_log(snac, xs_fmt("timeline_add %s", id));
|
snac_log(snac, xs_fmt("timeline_add %s", id));
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
17
http.c
17
http.c
|
@ -17,7 +17,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
{
|
{
|
||||||
xs *l1;
|
xs *l1;
|
||||||
xs *date;
|
xs *date;
|
||||||
xs *digest;
|
xs *digest_b64, *digest;
|
||||||
xs *s64;
|
xs *s64;
|
||||||
xs *signature;
|
xs *signature;
|
||||||
xs *hdrs;
|
xs *hdrs;
|
||||||
|
@ -25,6 +25,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
char *target;
|
char *target;
|
||||||
char *seckey;
|
char *seckey;
|
||||||
char *k, *v;
|
char *k, *v;
|
||||||
|
d_char *response;
|
||||||
|
|
||||||
date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT");
|
date = xs_utc_time("%a, %d %b %Y %H:%M:%S GMT");
|
||||||
|
|
||||||
|
@ -43,9 +44,11 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
|
|
||||||
/* digest */
|
/* digest */
|
||||||
if (body != NULL)
|
if (body != NULL)
|
||||||
digest = xs_sha256_base64(body, b_size);
|
digest_b64 = xs_sha256_base64(body, b_size);
|
||||||
else
|
else
|
||||||
digest = xs_sha256_base64("", 0);
|
digest_b64 = xs_sha256_base64("", 0);
|
||||||
|
|
||||||
|
digest = xs_fmt("SHA-256=%s", digest_b64);
|
||||||
|
|
||||||
seckey = xs_dict_get(snac->key, "secret");
|
seckey = xs_dict_get(snac->key, "secret");
|
||||||
|
|
||||||
|
@ -53,7 +56,7 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
/* build the string to be signed */
|
/* build the string to be signed */
|
||||||
xs *s = xs_fmt("(request-target): %s /%s\n"
|
xs *s = xs_fmt("(request-target): %s /%s\n"
|
||||||
"host: %s\n"
|
"host: %s\n"
|
||||||
"digest: SHA-256=%s\n"
|
"digest: %s\n"
|
||||||
"date: %s",
|
"date: %s",
|
||||||
strcmp(method, "POST") == 0 ? "post" : "get",
|
strcmp(method, "POST") == 0 ? "post" : "get",
|
||||||
target, host, digest, date);
|
target, host, digest, date);
|
||||||
|
@ -81,6 +84,10 @@ d_char *http_signed_request(snac *snac, char *method, char *url,
|
||||||
hdrs = xs_dict_append(hdrs, "digest", digest);
|
hdrs = xs_dict_append(hdrs, "digest", digest);
|
||||||
hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x");
|
hdrs = xs_dict_append(hdrs, "user-agent", "snac/2.x");
|
||||||
|
|
||||||
return xs_http_request(method, url, hdrs,
|
response = xs_http_request(method, url, hdrs,
|
||||||
body, b_size, status, payload, p_size);
|
body, b_size, status, payload, p_size);
|
||||||
|
|
||||||
|
srv_archive("SEND", hdrs, body, b_size, *status, response, *payload, *p_size);
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -56,7 +56,7 @@ d_char *timeline_find(snac *snac, char *id);
|
||||||
void timeline_del(snac *snac, char *id);
|
void timeline_del(snac *snac, char *id);
|
||||||
d_char *timeline_get(snac *snac, char *fn);
|
d_char *timeline_get(snac *snac, char *fn);
|
||||||
d_char *timeline_list(snac *snac);
|
d_char *timeline_list(snac *snac);
|
||||||
void timeline_add(snac *snac, char *id, char *msg, char *parent);
|
int timeline_add(snac *snac, char *id, char *msg, char *parent);
|
||||||
void timeline_admire(snac *snac, char *id, char *admirer, int like);
|
void timeline_admire(snac *snac, char *id, char *admirer, int like);
|
||||||
|
|
||||||
int following_add(snac *snac, char *actor, char *msg);
|
int following_add(snac *snac, char *actor, char *msg);
|
||||||
|
|
Loading…
Reference in a new issue