66 "github.com/drone/drone-template-lib/template"
77 "github.com/matrix-org/gomatrix"
88 "github.com/pkg/errors"
9+ "github.com/microcosm-cc/bluemonday"
10+ "gopkg.in/russross/blackfriday.v2"
911)
1012
1113type (
@@ -74,7 +76,7 @@ func (p Plugin) Exec() error {
7476 m .SetCredentials (r .UserID , r .AccessToken )
7577 }
7678
77- joined , err := m .JoinRoom (p .Config .RoomID , "" , nil )
79+ joined , err := m .JoinRoom (prepend ( "!" , p .Config .RoomID ) , "" , nil )
7880
7981 if err != nil {
8082 return errors .Wrap (err , "failed to join room" )
@@ -86,7 +88,18 @@ func (p Plugin) Exec() error {
8688 return errors .Wrap (err , "failed to render template" )
8789 }
8890
89- if _ , err := m .SendNotice (joined .RoomID , message ); err != nil {
91+ formatted := bluemonday .UGCPolicy ().SanitizeBytes (
92+ blackfriday .Run ([]byte (message )),
93+ )
94+
95+ content := gomatrix.HTMLMessage {
96+ Body : message ,
97+ MsgType : "m.notice" ,
98+ Format : "org.matrix.custom.html" ,
99+ FormattedBody : string (formatted ),
100+ }
101+
102+ if _ , err := m .SendMessageEvent (joined .RoomID , "m.room.message" , content ); err != nil {
90103 return errors .Wrap (err , "failed to submit message" )
91104 }
92105
0 commit comments