From 68d8da7290fa5a6d06f9d58bb8886eaba7cdbf5e Mon Sep 17 00:00:00 2001 From: Luke Miller Date: Sun, 2 May 2021 23:34:05 -0400 Subject: [PATCH] drafting consent module --- modpol/modules/consent.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/modpol/modules/consent.lua b/modpol/modules/consent.lua index e69de29..bfbad19 100644 --- a/modpol/modules/consent.lua +++ b/modpol/modules/consent.lua @@ -0,0 +1,37 @@ +rough_idea = { -- a lot of these might want to call org functions instead of being hard coded + type = "consent", + org_id = 5, -- may be needed for defer_to, process sent to a diff org + request_id = 1, -- callback to request + total_votes = 2, + to_pass = 3, -- could default to majority, but could set super majority + eligible_voters = 5, + timeout = 234235325, -- timestamp when vote ends + votes_yes = { + "lukvmil" + }, + votes_no = { + "nathan" + } +} + +function modules.consent.cast_vote(user, decision, org_id, process_id) + local org = modpol.orgs.get_org(org_id) + local process = org:get_process(process_id) + if decision == "yes" then + table.insert(process.votes_yes, user) + elseif decision == "no" then + table.insert(process.votes_no, user) + else + return false + + process.total_votes = process.total_votes + 1 + call_vote_check(process) -- some call to determine if the vote has reached an end condition +end + +function modules.consent.call_vote_check(process) + if votes_yes > to_pass then + call_success() + elseif votes_no > to_pass then + call_failure() + end +end \ No newline at end of file