mirror of
https://github.com/markqvist/lxmf_messageboard.git
synced 2024-10-01 02:25:36 -04:00
Added allow list (default off)
* Added an option for an allow list (`/storage/allowed`), if the file is present the users source address is checked against the list, if its not present they will be messaged to say they aren't authorised. Please note this feature is not default and only activates in the allowed file is present.
This commit is contained in:
parent
adfd531314
commit
845b89ae75
@ -33,6 +33,17 @@ def lxmf_delivery(message):
|
||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
||||
new_message = '{} {}: {}\n'.format(time_string, username, message_content)
|
||||
|
||||
# If an allowed file is present then check to see if a user is authorised
|
||||
if os.path.isfile(allowedpath):
|
||||
f = open(allowedpath, "rb")
|
||||
allowed_list = msgpack.unpack(f)
|
||||
f.close()
|
||||
if source_hash_text not in allowed_list:
|
||||
# Send reply
|
||||
message_reply = '{}_{}_You aren\'t authorised to post to this message board '.format(source_hash_text, time.time())
|
||||
q.put(message_reply)
|
||||
return
|
||||
|
||||
# Push message to board
|
||||
# First read message board (if it exists
|
||||
if os.path.isfile(boardpath):
|
||||
@ -139,6 +150,7 @@ if not os.path.isdir(storagepath):
|
||||
identitypath = configdir+"/storage/identity"
|
||||
announcepath = configdir+"/storage/announce"
|
||||
boardpath = configdir+"/storage/board"
|
||||
allowedpath = configdir+"/storage/allowed"
|
||||
|
||||
# Message Queue
|
||||
q = Queue(maxsize = 5)
|
||||
|
Loading…
Reference in New Issue
Block a user