Add toggle to only send to verified devices
This commit is contained in:
parent
ead7e0bf1d
commit
ee3594db46
@ -63,6 +63,7 @@ type Config struct {
|
|||||||
RoomCacheAge int64 `yaml:"room_cache_age"`
|
RoomCacheAge int64 `yaml:"room_cache_age"`
|
||||||
|
|
||||||
NotifySound bool `yaml:"notify_sound"`
|
NotifySound bool `yaml:"notify_sound"`
|
||||||
|
SendToVerifiedOnly bool `yaml:"send_to_verified_only"`
|
||||||
|
|
||||||
Dir string `yaml:"-"`
|
Dir string `yaml:"-"`
|
||||||
DataDir string `yaml:"data_dir"`
|
DataDir string `yaml:"data_dir"`
|
||||||
@ -97,6 +98,7 @@ func NewConfig(configDir, dataDir, cacheDir, downloadDir string) *Config {
|
|||||||
RoomCacheAge: 1 * 60,
|
RoomCacheAge: 1 * 60,
|
||||||
|
|
||||||
NotifySound: true,
|
NotifySound: true,
|
||||||
|
SendToVerifiedOnly: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -28,4 +28,4 @@ require (
|
|||||||
maunium.net/go/tcell v0.2.0
|
maunium.net/go/tcell v0.2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace maunium.net/go/mautrix => github.com/nikofil/mautrix-go v0.5.2-0.20200725145808-be3336827da7
|
replace maunium.net/go/mautrix => github.com/nikofil/mautrix-go v0.5.2-0.20200725175335-dd3f90913c4d
|
||||||
|
4
go.sum
4
go.sum
@ -33,6 +33,10 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
|
|||||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||||
github.com/nikofil/mautrix-go v0.5.2-0.20200725145808-be3336827da7 h1:w5IiIpetgAwalLPFkxiVbxBXJtcB9zLhoGLkyouQb4k=
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725145808-be3336827da7 h1:w5IiIpetgAwalLPFkxiVbxBXJtcB9zLhoGLkyouQb4k=
|
||||||
github.com/nikofil/mautrix-go v0.5.2-0.20200725145808-be3336827da7/go.mod h1:Va/74MijqaS0DQ3aUqxmFO54/PMfr1LVsCOcGRHbYmo=
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725145808-be3336827da7/go.mod h1:Va/74MijqaS0DQ3aUqxmFO54/PMfr1LVsCOcGRHbYmo=
|
||||||
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725165923-cae799088b7e h1:K8D+9n29FP1Utrv2joUhjcuDL1zC+Qq9rEFdV5kPgTQ=
|
||||||
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725165923-cae799088b7e/go.mod h1:Va/74MijqaS0DQ3aUqxmFO54/PMfr1LVsCOcGRHbYmo=
|
||||||
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725175335-dd3f90913c4d h1:tsCIy4CvvAeFEoBhet7zGoZXc+lr/e2YogoPaEGdMN8=
|
||||||
|
github.com/nikofil/mautrix-go v0.5.2-0.20200725175335-dd3f90913c4d/go.mod h1:Va/74MijqaS0DQ3aUqxmFO54/PMfr1LVsCOcGRHbYmo=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
||||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
|
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
|
||||||
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
|
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
|
||||||
|
@ -55,7 +55,9 @@ func (c *Container) initCrypto() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to open crypto store")
|
return errors.Wrap(err, "failed to open crypto store")
|
||||||
}
|
}
|
||||||
c.crypto = crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
|
crypt := crypto.NewOlmMachine(c.client, cryptoLogger{}, cryptoStore, c.config.Rooms)
|
||||||
|
crypt.AllowUnverifiedDevices = !c.config.SendToVerifiedOnly
|
||||||
|
c.crypto = crypt
|
||||||
err = c.crypto.Load()
|
err = c.crypto.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to create olm machine")
|
return errors.Wrap(err, "failed to create olm machine")
|
||||||
|
@ -158,6 +158,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
|||||||
"device": cmdDevice,
|
"device": cmdDevice,
|
||||||
"unverify": cmdUnverify,
|
"unverify": cmdUnverify,
|
||||||
"blacklist": cmdBlacklist,
|
"blacklist": cmdBlacklist,
|
||||||
|
"reset-session": cmdResetSession,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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())
|
_, _ = fmt.Fprintf(&buf, "%s (%s) - %s\n Fingerprint: %s\n", device.DeviceID, device.Name, device.Trust.String(), device.Fingerprint())
|
||||||
}
|
}
|
||||||
resp := buf.String()
|
resp := buf.String()
|
||||||
cmd.Reply(resp[:len(resp)-1])
|
cmd.Reply("%s", resp[:len(resp)-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdDevice(cmd *Command) {
|
func cmdDevice(cmd *Command) {
|
||||||
@ -561,6 +561,15 @@ func cmdBlacklist(cmd *Command) {
|
|||||||
putDevice(cmd, device, action)
|
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
|
// endregion
|
||||||
|
|
||||||
func cmdHeapProfile(cmd *Command) {
|
func cmdHeapProfile(cmd *Command) {
|
||||||
@ -638,7 +647,7 @@ func cmdHelp(cmd *Command) {
|
|||||||
/logout - Log out of Matrix.
|
/logout - Log out of Matrix.
|
||||||
/toggle <thing> - Temporary command to toggle various UI features.
|
/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
|
# Sending special messages
|
||||||
/me <message> - Send an emote message.
|
/me <message> - Send an emote message.
|
||||||
@ -919,6 +928,7 @@ var toggleMsg = map[string]ToggleMessage{
|
|||||||
"markdown": SimpleToggleMessage("markdown input"),
|
"markdown": SimpleToggleMessage("markdown input"),
|
||||||
"downloads": SimpleToggleMessage("automatic downloads"),
|
"downloads": SimpleToggleMessage("automatic downloads"),
|
||||||
"notifications": SimpleToggleMessage("desktop notifications"),
|
"notifications": SimpleToggleMessage("desktop notifications"),
|
||||||
|
"unverified": SimpleToggleMessage("sending messages to unverified devices"),
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeUsage() string {
|
func makeUsage() string {
|
||||||
@ -959,6 +969,8 @@ func cmdToggle(cmd *Command) {
|
|||||||
val = &cmd.Config.Preferences.DisableDownloads
|
val = &cmd.Config.Preferences.DisableDownloads
|
||||||
case "notifications":
|
case "notifications":
|
||||||
val = &cmd.Config.Preferences.DisableNotifications
|
val = &cmd.Config.Preferences.DisableNotifications
|
||||||
|
case "unverified":
|
||||||
|
val = &cmd.Config.SendToVerifiedOnly
|
||||||
default:
|
default:
|
||||||
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
cmd.Reply("Unknown toggle %s. Use /toggle without arguments for a list of togglable things.", thing)
|
||||||
return
|
return
|
||||||
|
@ -96,7 +96,9 @@ func NewVerificationModal(mainView *MainView, device *crypto.DeviceIdentity, tim
|
|||||||
|
|
||||||
vm.emojiText = &EmojiView{}
|
vm.emojiText = &EmojiView{}
|
||||||
|
|
||||||
vm.inputBar = mauview.NewInputField().SetBackgroundColor(tcell.ColorDefault)
|
vm.inputBar = mauview.NewInputField().
|
||||||
|
SetBackgroundColor(tcell.ColorDefault).
|
||||||
|
SetPlaceholderTextColor(tcell.ColorWhite)
|
||||||
|
|
||||||
flex := mauview.NewFlex().
|
flex := mauview.NewFlex().
|
||||||
SetDirection(mauview.FlexRow).
|
SetDirection(mauview.FlexRow).
|
||||||
@ -176,7 +178,7 @@ func (vm *VerificationModal) OnCancel(cancelledByUs bool, reason string, _ event
|
|||||||
} else {
|
} else {
|
||||||
vm.infoText.SetText(fmt.Sprintf("Verification cancelled by %s: %s", vm.device.UserID, reason))
|
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.done = true
|
||||||
vm.parent.parent.Render()
|
vm.parent.parent.Render()
|
||||||
}
|
}
|
||||||
@ -185,9 +187,13 @@ func (vm *VerificationModal) OnSuccess() {
|
|||||||
vm.waitingBar.SetIndeterminate(false).SetMax(100).SetProgress(100)
|
vm.waitingBar.SetIndeterminate(false).SetMax(100).SetProgress(100)
|
||||||
vm.parent.parent.app.SetRedrawTicker(1 * time.Minute)
|
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.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.done = true
|
||||||
vm.parent.parent.Render()
|
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 {
|
func (vm *VerificationModal) OnKeyEvent(event mauview.KeyEvent) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user