@ -1,5 +1,4 @@
use crate ::{
db_conn ::DbConn ,
lists ::List ,
posts ::Post ,
schema ::{ posts , timeline , timeline_definition } ,
@ -12,9 +11,9 @@ use std::ops::Deref;
pub ( crate ) mod query ;
pub use self ::query ::Kind ;
use self ::query ::{ QueryError , TimelineQuery } ;
pub use self ::query ::{ QueryError , TimelineQuery } ;
#[ derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)]
#[ derive(Clone, Debug, PartialEq, Eq, Queryable, Identifiable, AsChangeset)]
#[ table_name = " timeline_definition " ]
pub struct Timeline {
pub id : i32 ,
@ -220,7 +219,7 @@ impl Timeline {
. map_err ( Error ::from )
}
pub fn add_to_all_timelines ( conn : & Db Conn, post : & Post , kind : Kind < ' _ > ) -> Result < ( ) > {
pub fn add_to_all_timelines ( conn : & Connectio n, post : & Post , kind : Kind < ' _ > ) -> Result < ( ) > {
let timelines = timeline_definition ::table
. load ::< Self > ( conn . deref ( ) )
. map_err ( Error ::from ) ? ;
@ -246,7 +245,26 @@ impl Timeline {
Ok ( ( ) )
}
pub fn matches ( & self , conn : & DbConn , post : & Post , kind : Kind < ' _ > ) -> Result < bool > {
pub fn remove_post ( & self , conn : & Connection , post : & Post ) -> Result < bool > {
if self . includes_post ( conn , post ) ? {
return Ok ( false ) ;
}
diesel ::delete (
timeline ::table
. filter ( timeline ::timeline_id . eq ( self . id ) )
. filter ( timeline ::post_id . eq ( post . id ) ) ,
)
. execute ( conn ) ? ;
Ok ( true )
}
pub fn remove_all_posts ( & self , conn : & Connection ) -> Result < u64 > {
let count = diesel ::delete ( timeline ::table . filter ( timeline ::timeline_id . eq ( self . id ) ) )
. execute ( conn ) ? ;
Ok ( count as u64 )
}
pub fn matches ( & self , conn : & Connection , post : & Post , kind : Kind < ' _ > ) -> Result < bool > {
let query = TimelineQuery ::parse ( & self . query ) ? ;
query . matches ( conn , self , post , kind )
}
@ -282,73 +300,63 @@ mod tests {
fn test_timeline ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let users = userTests ::fill_database ( & conn ) ;
let users = userTests ::fill_database ( conn ) ;
let mut tl1_u1 = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"my timeline" . to_owned ( ) ,
"all" . to_owned ( ) ,
)
. unwrap ( ) ;
List ::new (
& conn ,
"languages I speak" ,
Some ( & users [ 1 ] ) ,
ListType ::Prefix ,
)
. unwrap ( ) ;
List ::new ( conn , "languages I speak" , Some ( & users [ 1 ] ) , ListType ::Prefix ) . unwrap ( ) ;
let tl2_u1 = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"another timeline" . to_owned ( ) ,
"followed" . to_owned ( ) ,
)
. unwrap ( ) ;
let tl1_u2 = Timeline ::new_for_user (
& conn ,
conn ,
users [ 1 ] . id ,
"english posts" . to_owned ( ) ,
"lang in \"languages I speak\"" . to_owned ( ) ,
)
. unwrap ( ) ;
let tl1_instance = Timeline ::new_for_instance (
& conn ,
conn ,
"english posts" . to_owned ( ) ,
"license in [cc]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert_eq! ( tl1_u1 , Timeline ::get ( & conn , tl1_u1 . id ) . unwrap ( ) ) ;
assert_eq! ( tl1_u1 , Timeline ::get ( conn , tl1_u1 . id ) . unwrap ( ) ) ;
assert_eq! (
tl2_u1 ,
Timeline ::find_for_user_by_name ( & conn , Some ( users [ 0 ] . id ) , "another timeline" )
Timeline ::find_for_user_by_name ( conn , Some ( users [ 0 ] . id ) , "another timeline" )
. unwrap ( )
) ;
assert_eq! (
tl1_instance ,
Timeline ::find_for_user_by_name ( & conn , None , "english posts" ) . unwrap ( )
Timeline ::find_for_user_by_name ( conn , None , "english posts" ) . unwrap ( )
) ;
let tl_u1 = Timeline ::list_for_user ( & conn , Some ( users [ 0 ] . id ) ) . unwrap ( ) ;
let tl_u1 = Timeline ::list_for_user ( conn , Some ( users [ 0 ] . id ) ) . unwrap ( ) ;
assert_eq! ( 3 , tl_u1 . len ( ) ) ; // it is not 2 because there is a "Your feed" tl created for each user automatically
assert! ( tl_u1 . iter ( ) . fold( false , | res , tl | { res | | * tl = = tl1_u1 } ) ) ;
assert! ( tl_u1 . iter ( ) . fold( false , | res , tl | { res | | * tl = = tl2_u1 } ) ) ;
assert! ( tl_u1 . iter ( ) . any( | tl | * tl = = tl1_u1 ) ) ;
assert! ( tl_u1 . iter ( ) . any( | tl | * tl = = tl2_u1 ) ) ;
let tl_instance = Timeline ::list_for_user ( & conn , None ) . unwrap ( ) ;
let tl_instance = Timeline ::list_for_user ( conn , None ) . unwrap ( ) ;
assert_eq! ( 3 , tl_instance . len ( ) ) ; // there are also the local and federated feed by default
assert! ( tl_instance
. iter ( )
. fold ( false , | res , tl | { res | | * tl = = tl1_instance } ) ) ;
assert! ( tl_instance . iter ( ) . any ( | tl | * tl = = tl1_instance ) ) ;
tl1_u1 . name = "My Super TL" . to_owned ( ) ;
let new_tl1_u2 = tl1_u2 . update ( & conn ) . unwrap ( ) ;
let new_tl1_u2 = tl1_u2 . update ( conn ) . unwrap ( ) ;
let tl_u2 = Timeline ::list_for_user ( & conn , Some ( users [ 1 ] . id ) ) . unwrap ( ) ;
let tl_u2 = Timeline ::list_for_user ( conn , Some ( users [ 1 ] . id ) ) . unwrap ( ) ;
assert_eq! ( 2 , tl_u2 . len ( ) ) ; // same here
assert! ( tl_u2
. iter ( )
. fold ( false , | res , tl | { res | | * tl = = new_tl1_u2 } ) ) ;
assert! ( tl_u2 . iter ( ) . any ( | tl | * tl = = new_tl1_u2 ) ) ;
Ok ( ( ) )
} ) ;
@ -358,48 +366,48 @@ mod tests {
fn test_timeline_creation_error ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let users = userTests ::fill_database ( & conn ) ;
let users = userTests ::fill_database ( conn ) ;
assert! ( Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"my timeline" . to_owned ( ) ,
"invalid keyword" . to_owned ( ) ,
)
. is_err ( ) ) ;
assert! ( Timeline ::new_for_instance (
& conn ,
conn ,
"my timeline" . to_owned ( ) ,
"invalid keyword" . to_owned ( ) ,
)
. is_err ( ) ) ;
assert! ( Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"my timeline" . to_owned ( ) ,
"author in non_existant_list" . to_owned ( ) ,
)
. is_err ( ) ) ;
assert! ( Timeline ::new_for_instance (
& conn ,
conn ,
"my timeline" . to_owned ( ) ,
"lang in dont-exist" . to_owned ( ) ,
)
. is_err ( ) ) ;
List ::new ( & conn , "friends" , Some ( & users [ 0 ] ) , ListType ::User ) . unwrap ( ) ;
List ::new ( & conn , "idk" , None , ListType ::Blog ) . unwrap ( ) ;
List ::new ( conn , "friends" , Some ( & users [ 0 ] ) , ListType ::User ) . unwrap ( ) ;
List ::new ( conn , "idk" , None , ListType ::Blog ) . unwrap ( ) ;
assert! ( Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"my timeline" . to_owned ( ) ,
"blog in friends" . to_owned ( ) ,
)
. is_err ( ) ) ;
assert! ( Timeline ::new_for_instance (
& conn ,
conn ,
"my timeline" . to_owned ( ) ,
"not author in idk" . to_owned ( ) ,
)
@ -413,10 +421,10 @@ mod tests {
fn test_simple_match ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let ( users , blogs ) = blogTests ::fill_database ( & conn ) ;
let ( users , blogs ) = blogTests ::fill_database ( conn ) ;
let gnu_tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"GNU timeline" . to_owned ( ) ,
"license in [AGPL, LGPL, GPL]" . to_owned ( ) ,
@ -424,7 +432,7 @@ mod tests {
. unwrap ( ) ;
let gnu_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug" . to_string ( ) ,
@ -440,10 +448,10 @@ mod tests {
} ,
)
. unwrap ( ) ;
assert! ( gnu_tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
assert! ( gnu_tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
let non_free_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug2" . to_string ( ) ,
@ -460,7 +468,7 @@ mod tests {
)
. unwrap ( ) ;
assert! ( ! gnu_tl
. matches ( & conn , & non_free_post , Kind ::Original )
. matches ( conn , & non_free_post , Kind ::Original )
. unwrap ( ) ) ;
Ok ( ( ) )
@ -471,9 +479,9 @@ mod tests {
fn test_complex_match ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let ( users , blogs ) = blogTests ::fill_database ( & conn ) ;
let ( users , blogs ) = blogTests ::fill_database ( conn ) ;
Follow ::insert (
& conn ,
conn ,
NewFollow {
follower_id : users [ 0 ] . id ,
following_id : users [ 1 ] . id ,
@ -483,11 +491,11 @@ mod tests {
. unwrap ( ) ;
let fav_blogs_list =
List ::new ( & conn , "fav_blogs" , Some ( & users [ 0 ] ) , ListType ::Blog ) . unwrap ( ) ;
fav_blogs_list . add_blogs ( & conn , & [ blogs [ 0 ] . id ] ) . unwrap ( ) ;
List ::new ( conn , "fav_blogs" , Some ( & users [ 0 ] ) , ListType ::Blog ) . unwrap ( ) ;
fav_blogs_list . add_blogs ( conn , & [ blogs [ 0 ] . id ] ) . unwrap ( ) ;
let my_tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"My timeline" . to_owned ( ) ,
"blog in fav_blogs and not has_cover or local and followed exclude likes"
@ -496,7 +504,7 @@ mod tests {
. unwrap ( ) ;
let post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "about-linux" . to_string ( ) ,
@ -512,10 +520,10 @@ mod tests {
} ,
)
. unwrap ( ) ;
assert! ( my_tl . matches ( & conn , & post , Kind ::Original ) . unwrap ( ) ) ; // matches because of "blog in fav_blogs" (and there is no cover)
assert! ( my_tl . matches ( conn , & post , Kind ::Original ) . unwrap ( ) ) ; // matches because of "blog in fav_blogs" (and there is no cover)
let post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 1 ] . id ,
slug : "about-linux-2" . to_string ( ) ,
@ -533,7 +541,7 @@ mod tests {
} ,
)
. unwrap ( ) ;
assert! ( ! my_tl . matches ( & conn , & post , Kind ::Like ( & users [ 1 ] ) ) . unwrap ( ) ) ;
assert! ( ! my_tl . matches ( conn , & post , Kind ::Like ( & users [ 1 ] ) ) . unwrap ( ) ) ;
Ok ( ( ) )
} ) ;
@ -543,17 +551,17 @@ mod tests {
fn test_add_to_all_timelines ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let ( users , blogs ) = blogTests ::fill_database ( & conn ) ;
let ( users , blogs ) = blogTests ::fill_database ( conn ) ;
let gnu_tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"GNU timeline" . to_owned ( ) ,
"license in [AGPL, LGPL, GPL]" . to_owned ( ) ,
)
. unwrap ( ) ;
let non_gnu_tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Stallman disapproved timeline" . to_owned ( ) ,
"not license in [AGPL, LGPL, GPL]" . to_owned ( ) ,
@ -561,7 +569,7 @@ mod tests {
. unwrap ( ) ;
let gnu_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug" . to_string ( ) ,
@ -579,7 +587,7 @@ mod tests {
. unwrap ( ) ;
let non_free_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug2" . to_string ( ) ,
@ -596,13 +604,13 @@ mod tests {
)
. unwrap ( ) ;
Timeline ::add_to_all_timelines ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ;
Timeline ::add_to_all_timelines ( & conn , & non_free_post , Kind ::Original ) . unwrap ( ) ;
Timeline ::add_to_all_timelines ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ;
Timeline ::add_to_all_timelines ( conn , & non_free_post , Kind ::Original ) . unwrap ( ) ;
let res = gnu_tl . get_latest ( & conn , 2 ) . unwrap ( ) ;
let res = gnu_tl . get_latest ( conn , 2 ) . unwrap ( ) ;
assert_eq! ( res . len ( ) , 1 ) ;
assert_eq! ( res [ 0 ] . id , gnu_post . id ) ;
let res = non_gnu_tl . get_latest ( & conn , 2 ) . unwrap ( ) ;
let res = non_gnu_tl . get_latest ( conn , 2 ) . unwrap ( ) ;
assert_eq! ( res . len ( ) , 1 ) ;
assert_eq! ( res [ 0 ] . id , non_free_post . id ) ;
@ -614,10 +622,10 @@ mod tests {
fn test_matches_lists_direct ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let ( users , blogs ) = blogTests ::fill_database ( & conn ) ;
let ( users , blogs ) = blogTests ::fill_database ( conn ) ;
let gnu_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug" . to_string ( ) ,
@ -634,63 +642,63 @@ mod tests {
)
. unwrap ( ) ;
gnu_post
. update_tags ( & conn , vec! [ Tag ::build_activity ( "free" . to_owned ( ) ) . unwrap ( ) ] )
. update_tags ( conn , vec! [ Tag ::build_activity ( "free" . to_owned ( ) ) . unwrap ( ) ] )
. unwrap ( ) ;
PostAuthor ::insert (
& conn ,
conn ,
NewPostAuthor {
post_id : gnu_post . id ,
author_id : blogs [ 0 ] . list_authors ( & conn ) . unwrap ( ) [ 0 ] . id ,
author_id : blogs [ 0 ] . list_authors ( conn ) . unwrap ( ) [ 0 ] . id ,
} ,
)
. unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"blog timeline" . to_owned ( ) ,
format! ( "blog in [{}]" , blogs [ 0 ] . fqn ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"blog timeline" . to_owned ( ) ,
"blog in [no_one@nowhere]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"author timeline" . to_owned ( ) ,
format! (
"author in [{}]" ,
blogs [ 0 ] . list_authors ( & conn ) . unwrap ( ) [ 0 ] . fqn
blogs [ 0 ] . list_authors ( conn ) . unwrap ( ) [ 0 ] . fqn
) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"author timeline" . to_owned ( ) ,
format! ( "author in [{}]" , users [ 2 ] . fqn ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
assert! ( tl
. matches ( & conn , & gnu_post , Kind ::Reshare ( & users [ 2 ] ) )
. matches ( conn , & gnu_post , Kind ::Reshare ( & users [ 2 ] ) )
. unwrap ( ) ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Like ( & users [ 2 ] ) ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Like ( & users [ 2 ] ) ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"author timeline" . to_owned ( ) ,
format! (
@ -699,50 +707,50 @@ mod tests {
) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
assert! ( ! tl
. matches ( & conn , & gnu_post , Kind ::Reshare ( & users [ 2 ] ) )
. matches ( conn , & gnu_post , Kind ::Reshare ( & users [ 2 ] ) )
. unwrap ( ) ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Like ( & users [ 2 ] ) ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Like ( & users [ 2 ] ) ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"tag timeline" . to_owned ( ) ,
"tags in [free]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"tag timeline" . to_owned ( ) ,
"tags in [private]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"english timeline" . to_owned ( ) ,
"lang in [en]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"franco-italian timeline" . to_owned ( ) ,
"lang in [fr, it]" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
Ok ( ( ) )
} ) ;
@ -786,10 +794,10 @@ mod tests {
fn test_matches_keyword ( ) {
let conn = & db ( ) ;
conn . test_transaction ::< _ , ( ) , _ > ( | | {
let ( users , blogs ) = blogTests ::fill_database ( & conn ) ;
let ( users , blogs ) = blogTests ::fill_database ( conn ) ;
let gnu_post = Post ::insert (
& conn ,
conn ,
NewPost {
blog_id : blogs [ 0 ] . id ,
slug : "slug" . to_string ( ) ,
@ -807,61 +815,61 @@ mod tests {
. unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Linux title" . to_owned ( ) ,
"title contains Linux" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Microsoft title" . to_owned ( ) ,
"title contains Microsoft" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Linux subtitle" . to_owned ( ) ,
"subtitle contains Stallman" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Microsoft subtitle" . to_owned ( ) ,
"subtitle contains Nadella" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Linux content" . to_owned ( ) ,
"content contains Linux" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
let tl = Timeline ::new_for_user (
& conn ,
conn ,
users [ 0 ] . id ,
"Microsoft content" . to_owned ( ) ,
"subtitle contains Windows" . to_owned ( ) ,
)
. unwrap ( ) ;
assert! ( ! tl . matches ( & conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( & conn ) . unwrap ( ) ;
assert! ( ! tl . matches ( conn , & gnu_post , Kind ::Original ) . unwrap ( ) ) ;
tl . delete ( conn ) . unwrap ( ) ;
Ok ( ( ) )
} ) ;