Added configuration option for ignoring messages with invalid stamps
This commit is contained in:
parent
c2881e70e9
commit
042726d27f
|
@ -2693,6 +2693,11 @@ class SidebandApp(MDApp):
|
|||
self.sideband.config["lxmf_ignore_unknown"] = self.settings_screen.ids.settings_lxmf_ignore_unknown.active
|
||||
self.sideband.save_configuration()
|
||||
|
||||
def save_lxmf_ignore_invalid_stamps(sender=None, event=None):
|
||||
self.sideband.config["lxmf_ignore_invalid_stamps"] = self.settings_screen.ids.settings_ignore_invalid_stamps.active
|
||||
self.sideband.save_configuration()
|
||||
self.sideband.update_ignore_invalid_stamps()
|
||||
|
||||
def save_lxmf_sync_limit(sender=None, event=None):
|
||||
self.sideband.config["lxmf_sync_limit"] = self.settings_screen.ids.settings_lxmf_sync_limit.active
|
||||
self.sideband.save_configuration()
|
||||
|
@ -2762,7 +2767,7 @@ class SidebandApp(MDApp):
|
|||
slider_val = int(self.settings_screen.ids.settings_lxmf_require_stamps_cost.value)
|
||||
cost_text = str(slider_val)
|
||||
|
||||
self.settings_screen.ids.settings_lxmf_require_stamps_label.text = f"Require stamp cost {cost_text} for inbound messages"
|
||||
self.settings_screen.ids.settings_lxmf_require_stamps_label.text = f"Require stamp cost {cost_text} for incoming messages"
|
||||
if save:
|
||||
if slider_val > 32:
|
||||
slider_val = 32
|
||||
|
@ -2826,6 +2831,9 @@ class SidebandApp(MDApp):
|
|||
self.settings_screen.ids.settings_lxmf_ignore_unknown.active = self.sideband.config["lxmf_ignore_unknown"]
|
||||
self.settings_screen.ids.settings_lxmf_ignore_unknown.bind(active=save_lxmf_ignore_unknown)
|
||||
|
||||
self.settings_screen.ids.settings_ignore_invalid_stamps.active = self.sideband.config["lxmf_ignore_invalid_stamps"]
|
||||
self.settings_screen.ids.settings_ignore_invalid_stamps.bind(active=save_lxmf_ignore_invalid_stamps)
|
||||
|
||||
self.settings_screen.ids.settings_lxmf_periodic_sync.active = self.sideband.config["lxmf_periodic_sync"]
|
||||
self.settings_screen.ids.settings_lxmf_periodic_sync.bind(active=save_lxmf_periodic_sync)
|
||||
save_lxmf_periodic_sync(save=False)
|
||||
|
|
|
@ -508,6 +508,8 @@ class SidebandCore():
|
|||
self.config["lxmf_try_propagation_on_fail"] = True
|
||||
if not "lxmf_require_stamps" in self.config:
|
||||
self.config["lxmf_require_stamps"] = False
|
||||
if not "lxmf_ignore_invalid_stamps" in self.config:
|
||||
self.config["lxmf_ignore_invalid_stamps"] = True
|
||||
if not "lxmf_inbound_stamp_cost" in self.config:
|
||||
self.config["lxmf_inbound_stamp_cost"] = None
|
||||
if not "notifications_on" in self.config:
|
||||
|
@ -746,6 +748,7 @@ class SidebandCore():
|
|||
if unpacked_config != None and len(unpacked_config) != 0:
|
||||
self.config = unpacked_config
|
||||
self.update_active_lxmf_propagation_node()
|
||||
self.update_ignore_invalid_stamps()
|
||||
except Exception as e:
|
||||
RNS.log("Error while reloading configuration: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
|
@ -3674,6 +3677,10 @@ class SidebandCore():
|
|||
configured_stamp_cost = self.config["lxmf_inbound_stamp_cost"]
|
||||
|
||||
self.lxmf_destination = self.message_router.register_delivery_identity(self.identity, display_name=self.config["display_name"], stamp_cost=configured_stamp_cost)
|
||||
if self.config["lxmf_ignore_invalid_stamps"]:
|
||||
self.message_router.enforce_stamps()
|
||||
else:
|
||||
self.message_router.ignore_stamps()
|
||||
|
||||
# TODO: Update to announce call in LXMF when full 0.5.0 support is added (get app data from LXMRouter instead)
|
||||
# Currently overrides the LXMF routers auto-generated announce data so that Sideband will announce old-format
|
||||
|
@ -3694,6 +3701,12 @@ class SidebandCore():
|
|||
else:
|
||||
self.set_active_propagation_node(None)
|
||||
|
||||
def update_ignore_invalid_stamps(self):
|
||||
if self.config["lxmf_ignore_invalid_stamps"]:
|
||||
self.message_router.enforce_stamps()
|
||||
else:
|
||||
self.message_router.ignore_stamps()
|
||||
|
||||
def message_notification_no_display(self, message):
|
||||
self.message_notification(message, no_display=True)
|
||||
|
||||
|
|
|
@ -1611,7 +1611,7 @@ MDScreen:
|
|||
|
||||
MDLabel:
|
||||
id: settings_lxmf_require_stamps_label
|
||||
text: "Require stamps for inbound messages"
|
||||
text: "Require stamps for incoming"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
|
@ -1635,6 +1635,22 @@ MDScreen:
|
|||
sensitivity: "all"
|
||||
hint: False
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
padding: [0,0,dp(24),dp(0)]
|
||||
height: dp(48)
|
||||
|
||||
MDLabel:
|
||||
text: "Ignore messages with invalid stamps"
|
||||
font_style: "H6"
|
||||
|
||||
MDSwitch:
|
||||
id: settings_ignore_invalid_stamps
|
||||
pos_hint: {"center_y": 0.3}
|
||||
disabled: False
|
||||
active: False
|
||||
|
||||
MDBoxLayout:
|
||||
orientation: "horizontal"
|
||||
size_hint_y: None
|
||||
|
|
|
@ -152,8 +152,12 @@ class Messages():
|
|||
valid_str = " is valid"
|
||||
sv = msg["extras"]["stamp_value"]
|
||||
if sv == None:
|
||||
sv_str = "was not included in the message"
|
||||
valid_str = ""
|
||||
if "stamp_raw" in msg["extras"]:
|
||||
sv_str = ""
|
||||
valid_str = "is not valid"
|
||||
else:
|
||||
sv_str = ""
|
||||
valid_str = "was not included in the message"
|
||||
elif sv > 255:
|
||||
sv_str = "generated from ticket"
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue