New function get_in_reply_to().

This commit is contained in:
default 2024-11-19 06:46:14 +01:00
parent 4daacf6b9d
commit 085caa7747
4 changed files with 19 additions and 6 deletions

View file

@ -183,6 +183,18 @@ const char *get_atto(const xs_dict *msg)
}
const char *get_in_reply_to(const xs_dict *msg)
/* gets the inReplyTo id */
{
const xs_val *in_reply_to = xs_dict_get(msg, "inReplyTo");
if (xs_type(in_reply_to) == XSTYPE_DICT)
in_reply_to = xs_dict_get(in_reply_to, "id");
return in_reply_to;
}
xs_list *get_attachments(const xs_dict *msg)
/* unify the garbage fire that are the attachments */
{
@ -373,7 +385,7 @@ int timeline_request(snac *snac, const char **id, xs_str **wrk, int level)
}
/* does it have an ancestor? */
const char *in_reply_to = xs_dict_get(object, "inReplyTo");
const char *in_reply_to = get_in_reply_to(object);
/* store */
timeline_add(snac, nid, object);
@ -671,7 +683,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
return 3;
/* is this message a reply to another? */
const char *irt = xs_dict_get(msg, "inReplyTo");
const char *irt = get_in_reply_to(msg);
if (!xs_is_null(irt)) {
xs *r_msg = NULL;
@ -1957,7 +1969,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
if (xs_match(utype, "Note|Article")) { /** **/
const char *id = xs_dict_get(object, "id");
const char *in_reply_to = xs_dict_get(object, "inReplyTo");
const char *in_reply_to = get_in_reply_to(object);
const char *atto = get_atto(object);
xs *wrk = NULL;

4
html.c
View file

@ -1670,7 +1670,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
if (strcmp(type, "Note") == 0) {
if (level == 0) {
/* is the parent not here? */
const char *parent = xs_dict_get(msg, "inReplyTo");
const char *parent = get_in_reply_to(msg);
if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) {
xs_html_add(post_header,
@ -2329,7 +2329,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
/* is this message a non-public reply? */
if (user != NULL && !is_msg_public(msg)) {
const char *irt = xs_dict_get(msg, "inReplyTo");
const char *irt = get_in_reply_to(msg);
/* is it a reply to something not in the storage? */
if (!xs_is_null(irt) && !object_here(irt)) {

View file

@ -1024,7 +1024,7 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
st = xs_dict_append(st, "in_reply_to_id", xs_stock(XSTYPE_NULL));
st = xs_dict_append(st, "in_reply_to_account_id", xs_stock(XSTYPE_NULL));
tmp = xs_dict_get(msg, "inReplyTo");
tmp = get_in_reply_to(msg);
if (!xs_is_null(tmp)) {
xs *irto = NULL;

1
snac.h
View file

@ -296,6 +296,7 @@ const char *default_avatar_base64(void);
xs_str *process_tags(snac *snac, const char *content, xs_list **tag);
const char *get_atto(const xs_dict *msg);
const char *get_in_reply_to(const xs_dict *msg);
xs_list *get_attachments(const xs_dict *msg);
xs_dict *msg_admiration(snac *snac, const char *object, const char *type);