-- JOIN ORG -- Module that enables a user to join an org JoinOrg = {} JoinOrg_mt = { __index = JoinOrg } function JoinOrg.create(initiator, org, id) local inst = { name = "Join an org", desc = "Initiator chooses an org to become a member of. Nothing happens if they are already in an org.", initiator = initiator, org = org, id = id } setmetatable(inst, JoinOrg_mt) return inst end function JoinOrg:initiate(result) modpol.interactions.binary_poll_user( self.initiator, "Would you like to join", function (resp) if resp == "Yes" then modpol.call_module( "consent", "", org, result ) modpol.modules.consent( "Let " .. initiator .. " join " .. org.name .. "?", org, params, self:on_failure, self:on_success ) -- for i, member in ipairs(org.members) do -- org:add_pending_action( -- member, -- function () -- modpol.interactions.binary_poll_user( -- member, -- "Let " .. initiator .. " join " .. org.name .. "?", -- function (resp) -- self:vote() -- end -- ) -- end -- ) -- end end end ) if result then result() end end function JoinOrg:request() end function JoinOrg:on_success() self.org:add_member(self.initiator) self.org:delete_process(self.id) end -- =================================== -- When calling a module internally modpol.modules.join_org_class = JoinOrg