aboutsummaryrefslogtreecommitdiffstats
path: root/adenosine-pds
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@robocracy.org>2023-03-04 19:30:05 -0800
committerbryan newbold <bnewbold@robocracy.org>2023-03-04 19:30:05 -0800
commit6942f47747f8655cf0702422f457f0476ab29c41 (patch)
treed826216b019d0a519b208621645dc5d777fb023a /adenosine-pds
parent215003c210ce205f85f6a1488f6fc41685ce1f1f (diff)
downloadadenosine-6942f47747f8655cf0702422f457f0476ab29c41.tar.gz
adenosine-6942f47747f8655cf0702422f457f0476ab29c41.zip
pds: updates for Thread schema hacks (for CLI)
Diffstat (limited to 'adenosine-pds')
-rw-r--r--adenosine-pds/src/db_bsky.rs20
-rw-r--r--adenosine-pds/templates/thread.html19
2 files changed, 26 insertions, 13 deletions
diff --git a/adenosine-pds/src/db_bsky.rs b/adenosine-pds/src/db_bsky.rs
index 5e968af..c51979e 100644
--- a/adenosine-pds/src/db_bsky.rs
+++ b/adenosine-pds/src/db_bsky.rs
@@ -218,7 +218,6 @@ fn feed_row_to_item(srv: &mut AtpService, row: FeedRow) -> Result<app_bsky::Feed
avatar: None,
viewer: None,
},
- repostedBy: None,
record: post_record,
embed: None,
replyCount: reply_count,
@@ -337,45 +336,49 @@ pub fn bsky_get_thread(
for row in rows {
let item = feed_row_to_item(srv, row)?.post;
children.push(app_bsky::ThreadPostView {
- post: app_bsky::PostView {
+ post: Some(app_bsky::PostView {
uri: item.uri,
cid: item.cid,
author: item.author,
record: item.record,
embed: item.embed,
- repostedBy: None,
replyCount: item.replyCount,
upvoteCount: item.upvoteCount,
downvoteCount: 0,
repostCount: item.repostCount,
indexedAt: item.indexedAt,
viewer: None,
- },
+ }),
// don't want a loop here
parent: None,
// only going to depth of one here
replies: None,
+ // for "notfound"
+ uri: None,
+ notFound: None,
});
}
let pip = post_item.post;
let post = app_bsky::ThreadPostView {
- post: app_bsky::PostView {
+ post: Some(app_bsky::PostView {
uri: pip.uri,
cid: pip.cid,
author: pip.author,
record: pip.record,
embed: pip.embed,
- repostedBy: None,
replyCount: pip.replyCount,
upvoteCount: pip.upvoteCount,
downvoteCount: 0,
repostCount: pip.repostCount,
indexedAt: pip.indexedAt,
viewer: None,
- },
+ }),
parent,
replies: Some(children),
+ // for "notfound" variant
+ uri: None,
+ notFound: None,
};
Ok(app_bsky::PostThread { thread: post })
}
@@ -614,7 +617,6 @@ fn test_bsky_feeds() {
// TODO: CID
assert_eq!(alice_feed.feed[2].post.author.did, alice_did.to_string());
assert_eq!(alice_feed.feed[2].post.author.handle, "alice.test");
- assert_eq!(alice_feed.feed[2].post.repostedBy, None);
assert_eq!(alice_feed.feed[2].post.record.text, "alice first post");
assert_eq!(alice_feed.feed[2].post.embed, None);
assert_eq!(alice_feed.feed[2].post.replyCount, 0);
@@ -657,8 +659,6 @@ fn test_bsky_feeds() {
// TODO: CID
assert_eq!(bob_feed.feed[1].author.did, alice_did.to_string());
assert_eq!(bob_feed.feed[1].author.handle, "alice.test");
- assert_eq!(bob_feed.feed[1].repostedBy.as_ref().unwrap().did, bob_did.to_string());
- assert_eq!(bob_feed.feed[1].repostedBy.as_ref().unwrap().handle, "bob.test");
// TODO: "is a repost" (check record?)
*/
diff --git a/adenosine-pds/templates/thread.html b/adenosine-pds/templates/thread.html
index c0a8684..9a3f935 100644
--- a/adenosine-pds/templates/thread.html
+++ b/adenosine-pds/templates/thread.html
@@ -4,16 +4,29 @@
{% block main %}
{% if post.parent.is_some() %}
- {% call macro::feed_item(post.parent.as_ref().unwrap().post) %}
+ {% let parent = post.parent.as_ref().unwrap() %}
+ {% if parent.post.is_some() %}
+ {% call macro::feed_item(parent.post.as_ref().unwrap()) %}
+ {% else %}
+ <p>Post not found!
+ {% endif %}
<center><i>---</i></center>
{% endif %}
-{% call macro::feed_item(post.post) %}
+{% if post.post.is_some() %}
+ {% call macro::feed_item(post.post.as_ref().unwrap()) %}
+{% else %}
+ <p>Post not found!
+{% endif %}
{% if post.replies.is_some() && post.replies.as_ref().unwrap().len() > 0 %}
<center><i>--- replies ---</i></center>
{% for item in post.replies.as_ref().unwrap() %}
- {% call macro::feed_item(item.post) %}
+ {% if item.post.is_some() %}
+ {% call macro::feed_item(item.post.as_ref().unwrap()) %}
+ {% else %}
+ <p>Post not found!
+ {% endif %}
{% endfor %}
{% endif %}