@@ -18,6 +18,7 @@ use diesel_async::{AsyncPgConnection, RunQueryDsl};
1818use diesel_uplete:: uplete;
1919use lemmy_api_utils:: {
2020 context:: LemmyContext ,
21+ plugins:: plugin_hook_after,
2122 send_activity:: { ActivityChannel , SendActivityData } ,
2223 utils:: send_webmention,
2324} ;
@@ -64,6 +65,11 @@ pub async fn setup(context: Data<LemmyContext>) -> LemmyResult<()> {
6465 // https://github.com/mdsherry/clokwerk/issues/38
6566 let mut scheduler = AsyncScheduler :: with_tz ( Utc ) ;
6667
68+ // Every 1 minute run plugin hooks
69+ scheduler. every ( CTimeUnits :: minutes ( 1 ) ) . run ( async move || {
70+ plugin_hook_after ( "scheduled_task_1_min" , & ( ) ) ;
71+ } ) ;
72+
6773 let context_1 = context. clone ( ) ;
6874 // Every 10 minutes update hot ranks, delete expired captchas and publish scheduled posts
6975 scheduler. every ( CTimeUnits :: minutes ( 10 ) ) . run ( move || {
@@ -78,6 +84,7 @@ pub async fn setup(context: Data<LemmyContext>) -> LemmyResult<()> {
7884 . await
7985 . inspect_err ( |e| warn ! ( "Failed to publish scheduled posts: {e}" ) )
8086 . ok ( ) ;
87+ plugin_hook_after ( "scheduled_task_10_mins" , & ( ) ) ;
8188 }
8289 } ) ;
8390
@@ -102,6 +109,7 @@ pub async fn setup(context: Data<LemmyContext>) -> LemmyResult<()> {
102109 . await
103110 . inspect_err ( |e| warn ! ( "Failed to delete expired instance bans: {e}" ) )
104111 . ok ( ) ;
112+ plugin_hook_after ( "scheduled_task_1_hour" , & ( ) ) ;
105113 }
106114 } ) ;
107115
@@ -141,6 +149,7 @@ pub async fn setup(context: Data<LemmyContext>) -> LemmyResult<()> {
141149 . await
142150 . inspect_err ( |e| warn ! ( "Failed to clear old activities: {e}" ) )
143151 . ok ( ) ;
152+ plugin_hook_after ( "scheduled_task_daily" , & ( ) ) ;
144153 }
145154 } ) ;
146155
0 commit comments