aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-07-25 20:54:32 +0300
committerTulir Asokan <tulir@maunium.net>2020-07-25 20:54:32 +0300
commitee3594db46fe261962f0a8a11c48cb9d6f84938f (patch)
treec12fc510597f33b82e17f630a00a3afb1e7849ab /ui
parentead7e0bf1d9c584224c1738b32ad26e314957220 (diff)
Add toggle to only send to verified devices
Diffstat (limited to 'ui')
-rw-r--r--ui/command-processor.go13
-rw-r--r--ui/commands.go16
-rw-r--r--ui/verification-modal.go12
3 files changed, 30 insertions, 11 deletions
diff --git a/ui/command-processor.go b/ui/command-processor.go
index 1b30cbe..514d67b 100644
--- a/ui/command-processor.go
+++ b/ui/command-processor.go
@@ -152,12 +152,13 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"cprof": cmdCPUProfile,
"trace": cmdTrace,
- "fingerprint": cmdFingerprint,
- "devices": cmdDevices,
- "verify": cmdVerify,
- "device": cmdDevice,
- "unverify": cmdUnverify,
- "blacklist": cmdBlacklist,
+ "fingerprint": cmdFingerprint,
+ "devices": cmdDevices,
+ "verify": cmdVerify,
+ "device": cmdDevice,
+ "unverify": cmdUnverify,
+ "blacklist": cmdBlacklist,
+ "reset-session": cmdResetSession,
},
}
}
diff --git a/ui/commands.go b/ui/commands.go
index a6309fd..1877c89 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -475,7 +475,7 @@ func cmdDevices(cmd *Command) {
_, _ = fmt.Fprintf(&buf, "%s (%s) - %s\n Fingerprint: %s\n", device.DeviceID, device.Name, device.Trust.String(), device.Fingerprint())
}
resp := buf.String()
- cmd.Reply(resp[:len(resp)-1])
+ cmd.Reply("%s", resp[:len(resp)-1])
}
func cmdDevice(cmd *Command) {
@@ -561,6 +561,15 @@ func cmdBlacklist(cmd *Command) {
putDevice(cmd, device, action)
}
+func cmdResetSession(cmd *Command) {
+ err := cmd.Matrix.Crypto().(*crypto.OlmMachine).CryptoStore.RemoveOutboundGroupSession(cmd.Room.Room.ID)
+ if err != nil {
+ cmd.Reply("Failed to remove outbound group session: %v", err)
+ } else {
+ cmd.Reply("Removed outbound group session for this room")
+ }
+}
+
// endregion
func cmdHeapProfile(cmd *Command) {
@@ -638,7 +647,7 @@ func cmdHelp(cmd *Command) {
/logout - Log out of Matrix.
/toggle <thing> - Temporary command to toggle various UI features.
-Things: rooms, users, baremessages, images, typingnotif
+Things: rooms, users, baremessages, images, typingnotif, unverified
# Sending special messages
/me <message> - Send an emote message.
@@ -919,6 +928,7 @@ var toggleMsg = map[string]ToggleMessage{
"markdown": SimpleToggleMessage("markdown input"),
"downloads": SimpleToggleMessage("automatic downloads"),
"notifications": SimpleToggleMessage("desktop notifications"),
+ "unverified": SimpleToggleMessage("sending messages to unverified devices"),
}
func makeUsage() string {
@@ -959,6 +969,8 @@ func cmdToggle(cmd *Command) {
val = &cmd.Config.Preferences.DisableDownloads
case "notifications":
val = &cmd.Config.Preferences.DisableNotifications
+ case "unverified":
+ val = &cmd.Config.SendToVerifiedOnly
default:
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
return
diff --git a/ui/verification-modal.go b/ui/verification-modal.go
index e47006e..54c2ecf 100644
--- a/ui/verification-modal.go
+++ b/ui/verification-modal.go
@@ -96,7 +96,9 @@ func NewVerificationModal(mainView *MainView, device *crypto.DeviceIdentity, tim
vm.emojiText = &EmojiView{}
- vm.inputBar = mauview.NewInputField().SetBackgroundColor(tcell.ColorDefault)
+ vm.inputBar = mauview.NewInputField().
+ SetBackgroundColor(tcell.ColorDefault).
+ SetPlaceholderTextColor(tcell.ColorWhite)
flex := mauview.NewFlex().
SetDirection(mauview.FlexRow).
@@ -176,7 +178,7 @@ func (vm *VerificationModal) OnCancel(cancelledByUs bool, reason string, _ event
} else {
vm.infoText.SetText(fmt.Sprintf("Verification cancelled by %s: %s", vm.device.UserID, reason))
}
- vm.inputBar.SetPlaceholder("Press enter to close dialog")
+ vm.inputBar.SetPlaceholder("Press enter to close the dialog")
vm.done = true
vm.parent.parent.Render()
}
@@ -185,9 +187,13 @@ func (vm *VerificationModal) OnSuccess() {
vm.waitingBar.SetIndeterminate(false).SetMax(100).SetProgress(100)
vm.parent.parent.app.SetRedrawTicker(1 * time.Minute)
vm.infoText.SetText(fmt.Sprintf("Successfully verified %s (%s) of %s", vm.device.Name, vm.device.DeviceID, vm.device.UserID))
- vm.inputBar.SetPlaceholder("Press enter to close dialog")
+ vm.inputBar.SetPlaceholder("Press enter to close the dialog")
vm.done = true
vm.parent.parent.Render()
+ if vm.parent.config.SendToVerifiedOnly {
+ // Hacky way to make new group sessions after verified
+ vm.parent.matrix.Crypto().(*crypto.OlmMachine).OnDevicesChanged(vm.device.UserID)
+ }
}
func (vm *VerificationModal) OnKeyEvent(event mauview.KeyEvent) bool {