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 Pin ned 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 . slf 4 j . LoggerFactory Ċ import Ġorg . springframework . stereotype . Component Ċ Ċ /** Ċ Ġ* ĠSends Ġnotification Ġwhen Ġpin ning Ġan Ġartifact Ċ Ġ*/ Ċ @ Component Ċ class ĠPin ned Notification Handler ( ĊĠ Ġprivate Ġval Ġslack Service : ĠSlack Service , ĊĠ Ġprivate Ġval Ġgit Data Generator : ĠGit Data Generator Ċ ) Ġ: ĠSlack Notification Handler < Slack Pin ned Notification > Ġ{ ĊĊĠ Ġoverride Ġval Ġsupported Types Ġ= ĠlistOf ( Notification Type . AR TI FACT _ PIN N ED ) ĊĠ Ġprivate Ġval Ġlog Ġby Ġlazy Ġ{ ĠLoggerFactory . getLogger ( java Class ) Ġ} ĊĊĠ Ġprivate Ġfun ĠSlack Pin ned Notification . header Text (): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġ" [$ application ] Ġ${ pinned Artifact . build Number Ġ?: Ġpinned Artifact . version } Ġis Ġpinned Ġto Ġ${ pin . target Environment . toLowerCase () }" ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠSlack Pin ned Notification . to Blocks (): ĠList < Layout Block > Ġ{ ĊĠĠĠ Ġreturn Ġwith Blocks Ġ{ ĊĠĠĠĠĠ Ġgit Data Generator . notification Body With Env ( this , Ġ": pin :", Ġapplication , Ġpinned Artifact , Ġ" pinned ", Ġpin . target Environment ) ĊĊĠĠĠĠĠ Ġpinned Artifact . git Metadata ?. let Ġ{ Ġgit Metadata Ġ-> ĊĠĠĠĠĠĠĠ Ġsection Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġgit Data Generator . generate Sc m Info ( this , Ġapplication , Ġgit Metadata , Ġpinned Artifact ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġval Ġusername Ġ= Ġpin . pinned By ?. let Ġ{ Ġslack Service . getUsername By Email ( it ) Ġ} ĊĠĠĠĠĠ Ġcontext Ġ{ ĊĠĠĠĠĠĠĠ Ġelements Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġmarkdown Text ("$ username Ġpinned Ġon Ġ<! date ^ ${ time . epoch Second }^{ date _ num } Ġ{ time _ secs }| fallback - text - include - P ST >: Ġ\" ${ pin . comment }\" ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠsendMessage ( ĊĠĠĠ Ġnotification : ĠSlack Pin ned Notification , ĊĠĠĠ Ġchannel : ĠString , ĊĠĠĠ Ġnotification Display : ĠNotification Display ĊĠ Ġ) Ġ{ ĊĠĠĠ Ġwith ( notification ) Ġ{ ĊĠĠĠĠĠ Ġlog . debug (" Sending Ġpinned Ġartifact Ġnotification Ġfor Ġapplication Ġ$ application ") ĊĊĠĠĠĠĠ Ġslack Service . send Slack Notification ( ĊĠĠĠĠĠĠĠ Ġchannel , ĊĠĠĠĠĠĠĠ Ġnotification . to Blocks (), ĊĠĠĠĠĠĠĠ Ġapplication Ġ= Ġapplication , ĊĠĠĠĠĠĠĠ Ġtype Ġ= Ġsupported Types , ĊĠĠĠĠĠĠĠ Ġfallback Text Ġ= Ġheader Text () ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ