From 6ea891ae8b0470c24af11a65a663526ee0ae690a Mon Sep 17 00:00:00 2001 From: nekobit Date: Fri, 5 Aug 2022 04:01:03 +0000 Subject: [PATCH] Perlify relationship FossilOrigin-Name: 08437db1c8a6eae47804c4687a67c5522b2b98b7464cc089229bf07fbbd8880a --- perl/account.pm | 5 ++-- src/account.c | 25 ++++++++++++++++ src/account.h | 1 + templates/account.tt | 69 ++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/perl/account.pm b/perl/account.pm index 2a0bb71..04e36a6 100644 --- a/perl/account.pm +++ b/perl/account.pm @@ -16,6 +16,7 @@ sub generate_account prefix => '', ssn => $ssn, content => $content, + acct => $acct, ); to_template(\%vars, \$data->{'account.tt'}); @@ -23,7 +24,7 @@ sub generate_account sub content_statuses { - my ($ssn, $data, $acct, $statuses) = @_; + my ($ssn, $data, $acct, $relationships, $statuses) = @_; my %vars = ( prefix => '', @@ -31,5 +32,5 @@ sub content_statuses acct => $acct, ); - generate_account($ssn, $data, $acct, to_template(\%vars, \$data->{'account_statuses.tt'})); + generate_account($ssn, $data, $acct, $relationships, to_template(\%vars, \$data->{'account_statuses.tt'})); } diff --git a/src/account.c b/src/account.c index 106ed9a..86c84ad 100644 --- a/src/account.c +++ b/src/account.c @@ -242,6 +242,10 @@ static char* account_statuses_cb(HV* session_hv, XPUSHs(newRV_noinc((SV*)session_hv)); XPUSHs(newRV_noinc((SV*)template_files)); XPUSHs(newRV_noinc((SV*)perlify_account(acct))); + if (rel) + XPUSHs(newRV_noinc((SV*)perlify_relationship(rel))); + else ARG_UNDEFINED(); + if (statuses) XPUSHs(newRV_noinc((SV*)perlify_statuses(statuses, statuses_len))); else ARG_UNDEFINED(); @@ -914,3 +918,24 @@ HV* perlify_account(const struct mstdnt_account* acct) return acct_hv; } + +HV* perlify_relationship(const struct mstdnt_relationship* rel) +{ + if (!rel) return NULL; + HV* rel_hv = newHV(); + + hvstores_str(rel_hv, "id", rel->id); + hvstores_int(rel_hv, "following", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_FOLLOWING)); + hvstores_int(rel_hv, "requested", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_REQUESTED)); + hvstores_int(rel_hv, "endoresed", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_ENDORSED)); + hvstores_int(rel_hv, "followed_by", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_FOLLOWED_BY)); + hvstores_int(rel_hv, "muting", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_MUTING)); + hvstores_int(rel_hv, "muting_notifs", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_MUTING_NOTIFS)); + hvstores_int(rel_hv, "showing_reblogs", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_SHOWING_REBLOGS)); + hvstores_int(rel_hv, "notifying", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_NOTIFYING)); + hvstores_int(rel_hv, "blocking", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_BLOCKING)); + hvstores_int(rel_hv, "domain_blocking", MSTDNT_T_FLAG_ISSET(rel, MSTDNT_RELATIONSHIP_DOMAIN_BLOCKING)); + hvstores_str(rel_hv, "blocked_by", rel->id); + + return rel_hv; +} diff --git a/src/account.h b/src/account.h index 1cbed18..3de5779 100644 --- a/src/account.h +++ b/src/account.h @@ -98,5 +98,6 @@ void content_account_favourites(PATH_ARGS); void content_account_bookmarks(PATH_ARGS); HV* perlify_account(const struct mstdnt_account* acct); +HV* perlify_relationship(const struct mstdnt_relationship* rel); #endif // ACCOUNT_H diff --git a/templates/account.tt b/templates/account.tt index 872571a..24ba858 100644 --- a/templates/account.tt +++ b/templates/account.tt @@ -1,3 +1,68 @@ -account +{{%s:is_blocked}} +{{%s:menubar}} +
+
+ {{%s:follows_you}} +
+ {{%s:display_name}} + {{%s:acct}} +
+ + + Menu + + +
+ + +
+ +
+
+ +{{%s:info}} + + + + + + + + +
+ + + + + + + +
+ +
+ {{%s:acct_content}} +
-[% content %]