package Ġcom . netflix . spin n aker . ke el . notifications . slack . handlers Ċ Ċ import Ġcom . netflix . spin n aker . ke el . api . Notification Display Ċ import Ġcom . netflix . spin n aker . ke el . notifications . Notification Type Ċ import Ġcom . netflix . spin n aker . ke el . notifications . slack . Slack Mark As Bad Notification Ċ import Ġcom . netflix . spin n aker . ke el . notifications . slack . Slack Service Ċ import Ġcom . slack . api . model . block . Layout Block Ċ import Ġcom . slack . api . model . kotlin _ extension . block . with Blocks Ċ import Ġorg . apache . logging . log 4 j . util . Strings Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . stereotype . Component Ċ Ċ /** Ċ Ġ* ĠSends Ġnotification Ġwhen Ġmarking Ġan Ġartifact Ġas Ġbad Ċ Ġ*/ Ċ @ Component Ċ class ĠMark As Bad Notification Handler ( ĊĠ Ġprivate Ġval Ġslack Service : ĠSlack Service , ĊĠ Ġprivate Ġval Ġgit Data Generator : ĠGit Data Generator , Ċ ) Ġ: ĠSlack Notification Handler < Slack Mark As Bad Notification > Ġ{ ĊĊĠ Ġoverride Ġval Ġsupported Types Ġ= ĠlistOf ( Notification Type . AR TI FACT _ MARK _ AS _ BAD ) ĊĠ Ġprivate Ġval Ġlog Ġby Ġlazy Ġ{ ĠLoggerFactory . getLogger ( java Class ) Ġ} ĊĊĠ Ġprivate Ġfun ĠSlack Mark As Bad Notification . header Text (): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġ" [$ application ] Ġ${ vet o ed Artifact . build Number Ġ?: Ġv eto ed Artifact . version } Ġmarked Ġas Ġbad Ġin Ġ${ target Environment . toLowerCase () }" ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠSlack Mark As Bad Notification . to Blocks (): ĠList < Layout Block > Ġ{ ĊĠĠĠ Ġval Ġusername Ġ= Ġslack Service . getUsername By Email ( user ) ĊĊĠĠĠ Ġreturn Ġwith Blocks Ġ{ ĊĠĠĠĠĠ Ġgit Data Generator . notification Body With Env ( this , Ġ": broken _ heart :", Ġapplication , Ġv eto ed Artifact , Ġ" marked Ġas Ġbad ", Ġtarget Environment , Ġpre position Ġ= Ġ" in ") ĊĊĠĠĠĠĠ Ġv eto ed Artifact . git Metadata ?. let Ġ{ Ġgit Metadata Ġ-> ĊĠĠĠĠĠĠĠ Ġsection Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġgit Data Generator . generate Sc m Info ( this , Ġapplication , Ġgit Metadata , Ġv eto ed Artifact ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġcontext Ġ{ ĊĠĠĠĠĠĠĠ Ġelements Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġmarkdown Text ("$ username Ġmarked Ġas Ġbad Ġon Ġ<! date ^ ${ time . epoch Second }^{ date _ num } Ġ{ time _ secs }| fallback - text - include - P ST >: Ġ\" ${ comment }\" ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠsendMessage ( ĊĠĠĠ Ġnotification : ĠSlack Mark As Bad Notification , ĊĠĠĠ Ġchannel : ĠString , ĊĠĠĠ Ġnotification Display : ĠNotification Display ĊĠ Ġ) Ġ{ ĊĠĠĠ Ġlog . debug (" Sending Ġmark Ġas Ġbad Ġartifact Ġnotification Ġfor Ġapplication Ġ${ notification . application }") ĊĊĠĠĠ Ġwith ( notification ) Ġ{ ĊĠĠĠĠĠ Ġslack Service . send Slack Notification ( ĊĠĠĠĠĠĠĠ Ġchannel , ĊĠĠĠĠĠĠĠ Ġnotification . to Blocks (), ĊĠĠĠĠĠĠĠ Ġapplication Ġ= Ġapplication , ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġsupported Types , ĊĠĠĠĠĠĠĠ Ġfallback Text Ġ= Ġheader Text () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ