aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-04-04 01:03:17 +0300
committerTulir Asokan <tulir@maunium.net>2020-04-04 01:03:17 +0300
commit842aab13243b0c14f20ae8a3a1d8501a33920501 (patch)
treeab624cbbd5c57ec80e4d933edce51be02b85d89e
parent0a493d643c3a15779dcee35583f8e5c59fde3031 (diff)
Add toggles for disabling markdown and HTML
-rw-r--r--config/config.go2
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--matrix/matrix.go4
-rw-r--r--ui/commands.go14
5 files changed, 21 insertions, 3 deletions
diff --git a/config/config.go b/config/config.go
index c223ee3..b8ff74b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -45,6 +45,8 @@ type UserPreferences struct {
DisableImages bool `yaml:"disable_images"`
DisableTypingNotifs bool `yaml:"disable_typing_notifs"`
DisableEmojis bool `yaml:"disable_emojis"`
+ DisableMarkdown bool `yaml:"disable_markdown"`
+ DisableHTML bool `yaml:"disable_html"`
}
// Config contains the main config of gomuks.
diff --git a/go.mod b/go.mod
index f72db5c..137267a 100644
--- a/go.mod
+++ b/go.mod
@@ -21,7 +21,7 @@ require (
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
gopkg.in/yaml.v2 v2.2.8
- maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592
+ maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f
maunium.net/go/mauview v0.1.0-beta.1
maunium.net/go/tcell v0.1.0
)
diff --git a/go.sum b/go.sum
index 1537220..371b37c 100644
--- a/go.sum
+++ b/go.sum
@@ -77,6 +77,8 @@ maunium.net/go/mautrix v0.1.0-beta.1.0.20200320123139-8ba1d97ed86b h1:sQ7w1dOTvT
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320123139-8ba1d97ed86b/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592 h1:WybA4BBUyod/qN6/yChfh2Q0CAqoZjtWnpUBwmfbfFU=
maunium.net/go/mautrix v0.1.0-beta.1.0.20200320135656-32dd5f172592/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
+maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f h1:Fg7t2i+AtUX4NDN5Ue9HsHO/Vog0JN9CZsOH3u+hDOc=
+maunium.net/go/mautrix v0.1.0-beta.2.0.20200403220206-c81fdd9fe68f/go.mod h1:YFMU9DBeXH7cqx7sJLg0DkVxwNPbih8QbpUTYf/IjMM=
maunium.net/go/mauview v0.1.0-beta.1 h1:hRprD6NTi5Mw7i97DKmgs/TzFQeNpGPytPoswNlU/Ww=
maunium.net/go/mauview v0.1.0-beta.1/go.mod h1:og9WbzmWe9SNYNyOFlCv8qa9zMcOvG2nzRJ5vYyud9U=
maunium.net/go/tcell v0.1.0 h1:XzsEoGCvOw5nac+tlkSLzQcliLYTN4PrtA7ar2ptjSM=
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 226df6c..e7fbcc3 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -392,7 +392,7 @@ func (c *Container) HandlePreferences(source EventSource, evt *mautrix.Event) {
func (c *Container) SendPreferencesToMatrix() {
defer debug.Recover()
debug.Print("Sending updated preferences:", c.config.Preferences)
- u := c.client.BuildURL("user", c.config.UserID, "account_data", "net.maunium.gomuks.preferences")
+ u := c.client.BuildURL("user", c.config.UserID, "account_data", AccountDataGomuksPreferences.Type)
_, err := c.client.MakeRequest("PUT", u, &c.config.Preferences, nil)
if err != nil {
debug.Print("Failed to update preferences:", err)
@@ -739,7 +739,7 @@ func (c *Container) PrepareMarkdownMessage(roomID string, msgtype mautrix.Messag
MsgType: msgtype,
}
} else {
- content = format.RenderMarkdown(text)
+ content = format.RenderMarkdown(text, !c.config.Preferences.DisableMarkdown, !c.config.Preferences.DisableHTML)
content.MsgType = msgtype
}
diff --git a/ui/commands.go b/ui/commands.go
index 8cfe55d..747be1e 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -556,6 +556,20 @@ func cmdToggle(cmd *Command) {
cmd.Config.Preferences.DisableTypingNotifs = !cmd.Config.Preferences.DisableTypingNotifs
case "emojis":
cmd.Config.Preferences.DisableEmojis = !cmd.Config.Preferences.DisableEmojis
+ case "html":
+ cmd.Config.Preferences.DisableHTML = !cmd.Config.Preferences.DisableHTML
+ if cmd.Config.Preferences.DisableHTML {
+ cmd.Reply("Disabled HTML input")
+ } else {
+ cmd.Reply("Enabled HTML input")
+ }
+ case "markdown":
+ cmd.Config.Preferences.DisableMarkdown = !cmd.Config.Preferences.DisableMarkdown
+ if cmd.Config.Preferences.DisableMarkdown {
+ cmd.Reply("Disabled Markdown input")
+ } else {
+ cmd.Reply("Enabled Markdown input")
+ }
default:
cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif/emojis>")
return