package Ġcom . r 3 . cord a . lib . chat . workflows . flows Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . r 3 . cord a . lib . chat . contracts . states . ChatMessage Ċ import Ġcom . r 3 . cord a . lib . chat . workflows . flows . internal . Create Message Flow Ċ import Ġcom . r 3 . cord a . lib . chat . workflows . flows . observer . Chat Notify Flow Ċ import Ġcom . r 3 . cord a . lib . chat . workflows . flows . observer . Reply Command Ċ import Ġcom . r 3 . cord a . lib . chat . workflows . flows . utils . chat Vault Service Ċ import Ġnet . cord a . core . contracts . State And Ref Ċ import Ġnet . cord a . core . contracts . Unique Identifier Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . utilities . unwrap Ċ Ċ @ Initi ating Flow Ċ @ Start able By Service Ċ @ Start able By RPC Ċ class ĠReply Chat Flow ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġchat Id : ĠUnique Identifier , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġcontent : ĠString Ċ ) Ġ: ĠFlow Logic < State And Ref < ChatMessage >>() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠState And Ref < ChatMessage > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmeta Info State Ref Ġ= Ġchat Vault Service . get Meta Info OrNull ( chat Id ) ĊĠĠĠĠĠĠĠ Ġrequire ( meta Info State Ref Ġ!= Ġnull ) Ġ{ Ġ" Chat Id Ġmust Ġexist ." Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġmeta Info Ġ= Ġmeta Info State Ref !!. state . data ĊĠĠĠĠĠĠĠ Ġrequire (( meta Info . re ceiv ers Ġ+ Ġmeta Info . admin ). contains ( our Identity )) Ġ{" Rep lier Ġmust Ġbe Ġin Ġexisting Ġparticipants "} ĊĊĠĠĠĠĠĠĠ Ġval Ġmessage State Ref Ġ= Ġsub Flow ( Create Message Flow ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġchat Id Ġ= Ġchat Id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontent Ġ= Ġcontent ĊĠĠĠĠĠĠĠ Ġ)) ĊĊĠĠĠĠĠĠĠ Ġ( meta Info . re ceiv ers Ġ+ Ġmeta Info . admin ). map Ġ{ Ġinitiate Flow ( it ). send ( message State Ref . state . data ) Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġmessage State Ref ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Initi ated By ( Reply Chat Flow :: class ) Ċ class ĠReply Chat Flow Responder ( private Ġval Ġother Session : ĠFlow Session ) Ġ: ĠFlow Logic < Unit >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġchat Message Ġ= Ġother Session . receive < ChatMessage >(). unwrap Ġ{ Ġit Ġ} ĊĠĠĠĠĠĠĠ Ġsub Flow ( Chat Notify Flow ( info Ġ= ĠlistOf ( chat Message ), Ġcommand Ġ= ĠReply Command ())) ĊĠĠĠ Ġ} Ċ } Ċ