mirror of
https://github.com/thegeeklab/wp-matrix.git
synced 2024-11-22 00:30:41 +00:00
Prefix room ids automatically with exclamation mark (#12)
* Prefix room ids automatically with exclamation mark * Fix markdown rendering to build proper links
This commit is contained in:
parent
edb1c3a8d0
commit
68bb1dd635
29
Gopkg.lock
generated
29
Gopkg.lock
generated
@ -24,21 +24,48 @@
|
||||
packages = ["."]
|
||||
revision = "a7fc80c8060c2544fe5d4dae465b584f8e9b4e27"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/microcosm-cc/bluemonday"
|
||||
packages = ["."]
|
||||
revision = "dafebb5b6ff2861a0d69af64991e10866c19be85"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/sanitized_anchor_name"
|
||||
packages = ["."]
|
||||
revision = "86672fcb3f950f35f2e675df2240550f2a50762f"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/urfave/cli"
|
||||
packages = ["."]
|
||||
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
|
||||
version = "v1.20.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"html",
|
||||
"html/atom"
|
||||
]
|
||||
revision = "f4c29de78a2a91c00474a2e689954305c350adf9"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/russross/blackfriday.v2"
|
||||
packages = ["."]
|
||||
revision = "cadec560ec52d93835bf2f15bd794700d3a2473b"
|
||||
version = "v2.0.0"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "e4283d82ea22e941f9ab4d2020b12f3721cd0235cb78cca670d2ae1105e148ef"
|
||||
inputs-digest = "243a217f076aeb5fdc8b28a2a2f38884c3476409410f664e316cd92acf44d012"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
@ -17,3 +17,11 @@
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/russross/blackfriday.v2"
|
||||
version = "2.0.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/microcosm-cc/bluemonday"
|
||||
version = "1.0.0"
|
||||
|
17
plugin.go
17
plugin.go
@ -6,6 +6,8 @@ import (
|
||||
"github.com/drone/drone-template-lib/template"
|
||||
"github.com/matrix-org/gomatrix"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -74,7 +76,7 @@ func (p Plugin) Exec() error {
|
||||
m.SetCredentials(r.UserID, r.AccessToken)
|
||||
}
|
||||
|
||||
joined, err := m.JoinRoom(p.Config.RoomID, "", nil)
|
||||
joined, err := m.JoinRoom(prepend("!", p.Config.RoomID), "", nil)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to join room")
|
||||
@ -86,7 +88,18 @@ func (p Plugin) Exec() error {
|
||||
return errors.Wrap(err, "failed to render template")
|
||||
}
|
||||
|
||||
if _, err := m.SendNotice(joined.RoomID, message); err != nil {
|
||||
formatted := bluemonday.UGCPolicy().SanitizeBytes(
|
||||
blackfriday.Run([]byte(message)),
|
||||
)
|
||||
|
||||
content := gomatrix.HTMLMessage{
|
||||
Body: message,
|
||||
MsgType: "m.notice",
|
||||
Format: "org.matrix.custom.html",
|
||||
FormattedBody: string(formatted),
|
||||
}
|
||||
|
||||
if _, err := m.SendMessageEvent(joined.RoomID, "m.room.message", content); err != nil {
|
||||
return errors.Wrap(err, "failed to submit message")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user