LXMF class improved, title and fields transport of distribution group and echo, added lxmf_provisioning server/script

This commit is contained in:
SebastianObi 2022-12-07 17:05:23 +01:00
parent 537a59cdd3
commit 81084f17f8
11 changed files with 1378 additions and 65 deletions

View File

@ -99,7 +99,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -111,6 +111,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -166,9 +167,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -368,8 +371,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -97,7 +97,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -109,6 +109,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -164,9 +165,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -366,8 +369,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -95,7 +95,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -107,6 +107,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -162,9 +163,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -364,8 +367,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -106,7 +106,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -118,6 +118,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -173,9 +174,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -375,8 +378,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -655,11 +669,19 @@ class rns_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
##############################################################################################################
@ -731,11 +753,16 @@ def lxmf_message_received_callback(message):
content = message.content.decode('utf-8')
content = content.strip()
if content == "":
if CONFIG["message"].getboolean("fields") and message.fields:
pass
elif content == "":
return
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
fields = message.fields
@ -805,6 +832,15 @@ def lxmf_message_received_callback(message):
else:
timestamp = time.time()
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
if CONFIG["statistic"].getboolean("enabled") and CONFIG["statistic"].getboolean("cluster"):
statistic("add", "cluster_in_" + message.desired_method_str)
@ -813,7 +849,7 @@ def lxmf_message_received_callback(message):
if "receive_cluster" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "cluster_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "cluster_send")
elif fields["m_t"] == "pin":
delimiter = CONFIG["interface"]["delimiter_output"]
@ -840,7 +876,7 @@ def lxmf_message_received_callback(message):
if "receive_cluster_pin_add" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content_group, "", {"type": CONFIG["lxmf"]["destination_type_conv"]}, None, "cluster_send")
LXMF_CONNECTION.send(key, content_group, "", fields, None, "cluster_send")
if CONFIG["main"].getboolean("auto_save_data"):
DATA.remove_option("main", "unsaved")
@ -1053,7 +1089,13 @@ def lxmf_message_received_callback(message):
if search != "":
content = re.sub(search, config_get(CONFIG, "message", "cluster_send_regex_replace"), content)
fields = defaultdict(dict)
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["c_n"] = CONFIG["cluster"]["name"]
fields["c_t"] = CONFIG["cluster"]["type"]
@ -1087,11 +1129,20 @@ def lxmf_message_received_callback(message):
if destination in config_get(CONFIG, "cluster", "display_name", "", lng_key).split("/"):
cluster_loop = True
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
for section in sections:
if "receive_cluster_send" in config_get(CONFIG, "rights", section).split(",") or (cluster_loop and "receive_cluster_loop" in config_get(CONFIG, "rights", section).split(",")):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "local_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "local_send")
return
@ -1136,6 +1187,15 @@ def lxmf_message_received_callback(message):
content = content_prefix + content + content_suffix
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
if config_get(CONFIG, "message", "timestamp", "", lng_key) == "client":
timestamp = message.timestamp
else:
@ -1153,7 +1213,7 @@ def lxmf_message_received_callback(message):
if "receive_local" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "local_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "local_send")
return
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " 'send' not allowed", LOG_DEBUG)
@ -3861,6 +3921,10 @@ pin_id = %%y%%m%%d-%%H%%M%%S
# Define which message timestamp should be used.
timestamp = client #client/server
# Use title/fields.
title = Yes
fields = Yes

View File

@ -93,7 +93,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -105,6 +105,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -160,9 +161,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -362,8 +365,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -538,8 +552,16 @@ def lxmf_message_received_callback(message):
if content == "":
return
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
if CONFIG["message"].getboolean("fields"):
fields = message.fields
else:
fields = None
source_hash = RNS.hexrep(message.source_hash, False)
source_name = ""
@ -617,7 +639,7 @@ def lxmf_message_received_callback(message):
if "receive" in section:
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, None, timestamp)
LXMF_CONNECTION.send(key, content, title, fields, timestamp)
return
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " 'send' not allowed", LOG_DEBUG)
@ -1267,6 +1289,10 @@ send_length_max = 0 #0=any length
# Define which message timestamp should be used.
timestamp = client #client/server
# Use title/fields.
title = Yes
fields = Yes
'''

View File

@ -91,7 +91,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -103,6 +103,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -158,9 +159,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -360,8 +363,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -581,7 +595,18 @@ def lxmf_message_received_callback(message):
content = content_prefix + content + content_suffix
LXMF_CONNECTION.send(message.source_hash, content, message.title.decode('utf-8').strip())
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
if CONFIG["message"].getboolean("fields"):
fields = message.fields
else:
fields = None
LXMF_CONNECTION.send(message.source_hash, content, title, fields)
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " not allowed", LOG_DEBUG)
return
@ -1106,6 +1131,10 @@ send_regex_replace =
send_length_min = 0 #0=any length
send_length_max = 0 #0=any length
# Use title/fields.
title = Yes
fields = Yes

View File

@ -92,7 +92,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -104,6 +104,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -159,9 +160,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -361,8 +364,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

View File

@ -0,0 +1,2 @@
# lxmf_provisioning
For more information, see the configuration options (at the end of the program files). Everything else is briefly documented there. After the first start this configuration will be created as default config in the corresponding file.

File diff suppressed because it is too large Load Diff

View File

@ -195,7 +195,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -207,6 +207,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -262,9 +263,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -464,8 +467,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)