refactored to simpler pending action system
This commit is contained in:
@@ -40,33 +40,25 @@ end
|
||||
|
||||
-- ===========================
|
||||
-- adds a new pending action to the org's table
|
||||
function modpol.orgs:add_pending_action(process_id, user, action)
|
||||
function modpol.orgs:add_pending_action(process_id, user)
|
||||
-- adds tables if they don't exist already
|
||||
self.pending[user] = self.pending[user] or {}
|
||||
self.pending[user][process_id] = self.pending[user][process_id] or {}
|
||||
-- flagging actual action
|
||||
self.pending[user][process_id] = true
|
||||
|
||||
-- inserting actual action
|
||||
table.insert(self.pending[user][process_id], action)
|
||||
modpol.ocutil.log("Added pending action '" .. action .. "' to " .. user .. " in process #" .. process_id)
|
||||
modpol.ocutil.log("Added pending action to " .. user .. " in process #" .. process_id)
|
||||
end
|
||||
|
||||
-- ========================
|
||||
-- removes a pending action from the org's table
|
||||
function modpol.orgs:remove_pending_action(process_id, user, action)
|
||||
-- cautiously checks if pending action exists before removing it
|
||||
function modpol.orgs:remove_pending_action(process_id, user)
|
||||
|
||||
if self.pending[user] then
|
||||
if self.pending[user][process_id] then
|
||||
-- searching for action to remove
|
||||
for i, a in pairs(self.pending[user][process_id]) do
|
||||
if a == action then
|
||||
self.pending[user][process_id][i] = nil
|
||||
modpol.ocutil.log("Removed pending action '" .. action .. "' from " .. user .. " in process #" .. process_id)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
self.pending[user][process_id] = nil
|
||||
modpol.ocutil.log("Removed pending action from " .. user .. " in process #" .. process_id)
|
||||
else
|
||||
modpol.ocutil.log("Could not remove pending action from " .. user .. " in process #" .. process_id)
|
||||
end
|
||||
modpol.ocutil.log("Could not remove pending action '" .. action .. "' from " .. user .. " in process #" .. process_id)
|
||||
end
|
||||
|
||||
-- =====================
|
||||
|
||||
Reference in New Issue
Block a user