From 3dd57d3bdc222b2ad644b7af84613049e7453145 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Fri, 20 May 2022 18:23:26 +0400 Subject: [PATCH] Added event orphaning for old hash types --- plugins/cron/init.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/cron/init.lua b/plugins/cron/init.lua index 3c5daeb..46e478e 100644 --- a/plugins/cron/init.lua +++ b/plugins/cron/init.lua @@ -81,7 +81,7 @@ local create_event = function(msg,cronjob,create_entry) type = functype } end - return true + return true,hash end local get_user_events = function(author_id,page) @@ -153,7 +153,14 @@ for k,v in pairs(config.events.timer) do if channel then local message = channel:getMessage(v.id) if message then - create_event(message,v.comm,true) + local status,hash = create_event(message,v.comm,true) + --orphan events with mismatching hashes + if status and (hash ~= k) then + log("WARNING", "Hash mismatch, orpahning event.") + events.timer[k] = nil + config.events.timer[k] = nil + create_event(message,v.comm) + end else log("ERROR","No message with id "..v.id) end @@ -170,7 +177,14 @@ for _,evtype in pairs(config.events.event) do if channel then local message = channel:getMessage(v.id) if message then - create_event(message,v.comm,true) + local status,hash = create_event(message,v.comm,true) + --orphan events with mismatching hashes + if status and (hash ~= k) then + log("WARNING", "Hash mismatch, orpahning event.") + events.event[_][k] = nil + config.events.event[_][k] = nil + create_event(message,v.comm) + end else log("ERROR","No message with id "..v.id) end