@@ -26,6 +26,7 @@ use middlewares::RequestSpan;
2626use pgvector:: Vector ;
2727use routes:: { health, index_repository} ;
2828use serde:: { Deserialize , Deserializer } ;
29+ use slack:: Slack ;
2930use sqlx:: {
3031 postgres:: { PgConnectOptions , PgPoolOptions } ,
3132 prelude:: FromRow ,
@@ -50,6 +51,7 @@ mod huggingface;
5051mod metrics;
5152mod middlewares;
5253mod routes;
54+ mod slack;
5355
5456#[ derive( Clone ) ]
5557pub struct AppState {
@@ -251,10 +253,11 @@ async fn handle_webhooks_wrapper(
251253 embedding_api : EmbeddingApi ,
252254 github_api : GithubApi ,
253255 huggingface_api : HuggingfaceApi ,
256+ slack : Slack ,
254257 pool : Pool < Postgres > ,
255258) -> anyhow:: Result < ( ) > {
256259 select ! {
257- res = handle_webhooks( rx, embedding_api, github_api, huggingface_api, pool) => { res } ,
260+ res = handle_webhooks( rx, embedding_api, github_api, huggingface_api, slack , pool) => { res } ,
258261 _ = shutdown_signal( ) => { Ok ( ( ) ) } ,
259262 }
260263}
@@ -264,6 +267,7 @@ async fn handle_webhooks(
264267 embedding_api : EmbeddingApi ,
265268 github_api : GithubApi ,
266269 huggingface_api : HuggingfaceApi ,
270+ slack : Slack ,
267271 pool : Pool < Postgres > ,
268272) -> anyhow:: Result < ( ) > {
269273 while let Some ( webhook_data) = rx. recv ( ) . await {
@@ -283,6 +287,15 @@ async fn handle_webhooks(
283287 . fetch_all ( & pool)
284288 . await ?;
285289
290+ slack
291+ . closest_issues (
292+ & issue. title ,
293+ issue. number ,
294+ & issue. html_url ,
295+ & closest_issues,
296+ )
297+ . await ?;
298+
286299 match ( issue. is_pull_request , & issue. source ) {
287300 ( false , Source :: Github ) => {
288301 github_api
@@ -296,7 +309,6 @@ async fn handle_webhooks(
296309 }
297310 _ => ( ) ,
298311 }
299- // TODO: send slack message
300312
301313 sqlx:: query (
302314 r#"insert into issues (source_id, source, title, body, is_pull_request, number, html_url, url, embedding)
@@ -569,6 +581,7 @@ async fn main() -> anyhow::Result<()> {
569581 let embedding_api = EmbeddingApi :: new ( config. model_api ) . await ?;
570582 let github_api = GithubApi :: new ( config. github_api , config. message_config . clone ( ) ) ?;
571583 let huggingface_api = HuggingfaceApi :: new ( config. huggingface_api , config. message_config ) ?;
584+ let slack = Slack :: new ( & config. slack ) ?;
572585
573586 let ( tx, rx) = mpsc:: channel ( 4_096 ) ;
574587
@@ -588,7 +601,7 @@ async fn main() -> anyhow::Result<()> {
588601 false ,
589602 setup_metrics_recorder( )
590603 ) ) ) ,
591- handle_webhooks_wrapper( rx, embedding_api, github_api, huggingface_api, pool)
604+ handle_webhooks_wrapper( rx, embedding_api, github_api, huggingface_api, slack , pool)
592605 ) ?;
593606
594607 Ok ( ( ) )
0 commit comments