Relationship::Root treated like Relationship::Reply

This commit is contained in:
Mike Dilger 2023-03-16 15:31:59 +13:00
parent 7203efb02e
commit 6894524df2
3 changed files with 18 additions and 1 deletions

View File

@ -176,7 +176,7 @@ impl Globals {
let mut output: Vec<Id> = Vec::new();
if let Some(vec) = GLOBALS.relationships.blocking_read().get(&id) {
for (id, relationship) in vec.iter() {
if *relationship == Relationship::Reply {
if *relationship == Relationship::Reply || *relationship == Relationship::Root {
output.push(*id);
}
}

View File

@ -156,6 +156,22 @@ pub async fn process_new_event(
Globals::add_relationship(id, event.id, Relationship::Reply).await;
}
// replies to root
if let Some((id, _)) = event.replies_to_root() {
if from_relay {
let db_event_relationship = DbEventRelationship {
original: event.id.as_hex_string(),
refers_to: id.as_hex_string(),
relationship: "root".to_string(),
content: None,
};
db_event_relationship.insert().await?;
}
// Insert into relationships
Globals::add_relationship(id, event.id, Relationship::Root).await;
}
// mentions
for (id, _) in event.mentions() {
if from_relay {

View File

@ -1,6 +1,7 @@
/// A relationship between events
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Relationship {
Root,
Reply,
Mention,
Reaction(String),