|
|
|
@ -25,11 +25,19 @@ logger = logging.getLogger(__name__) |
|
|
|
NOTIFICATION_FILE = '/home/shane/foodie_automator/notification_tracking.json' |
|
|
|
NOTIFICATION_FILE = '/home/shane/foodie_automator/notification_tracking.json' |
|
|
|
|
|
|
|
|
|
|
|
def load_notification_tracking(): |
|
|
|
def load_notification_tracking(): |
|
|
|
"""Load notification tracking data.""" |
|
|
|
"""Load notification tracking data as a dict. If not a dict, reset to {}.""" |
|
|
|
return load_json_file(NOTIFICATION_FILE, default={}) |
|
|
|
data = load_json_file(NOTIFICATION_FILE, default={}) |
|
|
|
|
|
|
|
if not isinstance(data, dict): |
|
|
|
|
|
|
|
logging.warning(f"notification_tracking.json was not a dict, resetting to empty dict.") |
|
|
|
|
|
|
|
data = {} |
|
|
|
|
|
|
|
save_json_file(NOTIFICATION_FILE, data) |
|
|
|
|
|
|
|
return data |
|
|
|
|
|
|
|
|
|
|
|
def save_notification_tracking(tracking_data): |
|
|
|
def save_notification_tracking(tracking_data): |
|
|
|
"""Save notification tracking data.""" |
|
|
|
"""Save notification tracking data as a dict.""" |
|
|
|
|
|
|
|
if not isinstance(tracking_data, dict): |
|
|
|
|
|
|
|
logging.warning(f"Attempted to save non-dict to notification_tracking.json, resetting to empty dict.") |
|
|
|
|
|
|
|
tracking_data = {} |
|
|
|
save_json_file(NOTIFICATION_FILE, tracking_data) |
|
|
|
save_json_file(NOTIFICATION_FILE, tracking_data) |
|
|
|
|
|
|
|
|
|
|
|
def should_send_notification(username, reset_time): |
|
|
|
def should_send_notification(username, reset_time): |
|
|
|
|