mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Persist MQTT Map report opt in and prevent proxy connections without accepting terms.
This commit is contained in:
parent
f6edb06e0e
commit
edc23ffc1a
2 changed files with 8 additions and 4 deletions
|
|
@ -46,7 +46,12 @@ class MqttClientProxyManager {
|
|||
let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh"
|
||||
let prefix = root!
|
||||
topic = prefix + "/2/e" + "/#"
|
||||
connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic)
|
||||
// Require opt in to map report terms to connect
|
||||
if node.mqttConfig?.mapReportingEnabled ?? false && UserDefaults.mapReportingOptIn || !(node.mqttConfig?.mapReportingEnabled ?? false) {
|
||||
connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic)
|
||||
} else {
|
||||
delegate?.onMqttError(message: "MQTT Map Reporting Terms need to be accepted.")
|
||||
}
|
||||
}
|
||||
}
|
||||
func connect(host: String, port: Int, useSsl: Bool, username: String?, password: String?, topic: String?) {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ struct MQTTConfig: View {
|
|||
@State var defaultTopic = "msh/US"
|
||||
@State var nearbyTopics = [String]()
|
||||
@State var mapReportingEnabled = false
|
||||
@State var mapReportingOptIn = false
|
||||
//@AppStorage("mapReportingOptIn") private var mapReportingOptIn: Bool = false
|
||||
@AppStorage("mapReportingOptIn") private var mapReportingOptIn: Bool = false
|
||||
@State var mapPublishIntervalSecs = 3600
|
||||
@State var mapPositionPrecision: Double = 14.0
|
||||
|
||||
|
|
@ -267,7 +266,7 @@ struct MQTTConfig: View {
|
|||
mqtt.encryptionEnabled = self.encryptionEnabled
|
||||
mqtt.jsonEnabled = self.jsonEnabled
|
||||
mqtt.tlsEnabled = self.tlsEnabled
|
||||
mqtt.mapReportingEnabled = (self.mapReportingEnabled && self.mapReportingOptIn)
|
||||
mqtt.mapReportingEnabled = self.mapReportingEnabled
|
||||
mqtt.mapReportSettings.positionPrecision = UInt32(self.mapPositionPrecision)
|
||||
mqtt.mapReportSettings.publishIntervalSecs = UInt32(self.mapPublishIntervalSecs)
|
||||
let adminMessageId = bleManager.saveMQTTConfig(config: mqtt, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue