aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stream/activity.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/stream/activity.rs b/src/stream/activity.rs
index 6020558..c247477 100644
--- a/src/stream/activity.rs
+++ b/src/stream/activity.rs
@@ -29,6 +29,11 @@ pub enum ActivityEncoding {
}
#[derive(Debug, Deserialize, PartialEq)]
+pub enum ObjectType {
+ Note,
+}
+
+#[derive(Debug, Deserialize, PartialEq)]
#[serde(rename_all="snake_case")]
pub enum ActivityFlag {
Direct,
@@ -63,6 +68,7 @@ pub struct Activity {
pub commented: DateTime,
pub verb: Verb,
+ pub object_type: ObjectType,
pub title: String,
pub summary: String,
@@ -78,7 +84,17 @@ pub struct Activity {
impl Activity {
pub fn is_post(&self) -> bool {
- self.verb == Verb::Post
+ self.verb == Verb::Create
+ && self.object_type == ObjectType::Note
+ && self.has_flag(ActivityFlag::ThreadParent)
+ }
+
+ pub fn has_flag(&self, flag: ActivityFlag) -> bool {
+ self.flags
+ .as_ref()
+ .map_or(
+ false,
+ |flags| flags.iter().find( |f| *f == &flag ).is_some())
}
}
@@ -181,6 +197,9 @@ mod test {
assert_eq!("2023-12-12 17:00:42", &item.edited.to_string());
assert_eq!("0000-00-00 00:00:00", &item.expires.to_string());
assert_eq!("2023-12-19 09:01:15", &item.commented.to_string());
- assert_eq!(ActivityFlag::ThreadParent, item.flags.as_ref().unwrap()[0]);
+ assert_eq!(ObjectType::Note, item.object_type);
+
+ assert_eq!(true, item.has_flag(ActivityFlag::ThreadParent));
+ assert_eq!(true, item.is_post());
}
}