2022-08-09 17:00:24 -06:00
|
|
|
--- Join org
|
|
|
|
|
-- Adds initiator to an org
|
2022-01-20 11:04:44 -07:00
|
|
|
-- @module join_org
|
2021-11-22 16:24:44 -05:00
|
|
|
|
2022-08-09 17:00:24 -06:00
|
|
|
local join_org = {
|
|
|
|
|
name = "Join this org (consent)",
|
|
|
|
|
slug = "join_org",
|
|
|
|
|
desc = "Adds member with consent of all members"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
join_org.data = {
|
|
|
|
|
result = nil
|
|
|
|
|
}
|
2021-11-22 16:24:44 -05:00
|
|
|
|
2022-08-09 17:00:24 -06:00
|
|
|
join_org.config = {
|
|
|
|
|
approval_module = false
|
2021-12-16 23:33:02 -07:00
|
|
|
}
|
|
|
|
|
|
2022-08-09 17:00:24 -06:00
|
|
|
--- Initiate join org with consent
|
|
|
|
|
-- @function join_org:initiate
|
2022-01-23 18:21:23 -07:00
|
|
|
-- @param result Callback if this module is embedded in other modules
|
2022-08-09 17:00:24 -06:00
|
|
|
function join_org:initiate(result)
|
|
|
|
|
if self.org:has_member(self.initiator) then
|
|
|
|
|
modpol.interactions.message(
|
|
|
|
|
self.initiator,
|
|
|
|
|
"You are already a member of this org")
|
|
|
|
|
if result then result() end
|
|
|
|
|
self.org:delete_process(self.id)
|
|
|
|
|
else
|
|
|
|
|
self.data.result = result
|
|
|
|
|
self:call_module(
|
|
|
|
|
self.config.approval_module,
|
|
|
|
|
self.initiator,
|
|
|
|
|
{
|
|
|
|
|
prompt = "Allow " .. self.initiator .. " to join?"
|
|
|
|
|
},
|
|
|
|
|
function ()
|
|
|
|
|
self:complete()
|
2021-11-22 16:24:44 -05:00
|
|
|
end
|
|
|
|
|
)
|
2022-08-09 17:00:24 -06:00
|
|
|
end
|
|
|
|
|
end
|
2021-11-22 16:24:44 -05:00
|
|
|
|
2022-08-09 17:00:24 -06:00
|
|
|
--- Adds member to org, notifies org, and deletes process
|
|
|
|
|
-- @function join_org:complete
|
|
|
|
|
function join_org:complete()
|
|
|
|
|
self.org:add_member(self.initiator)
|
|
|
|
|
modpol.interactions.message_org(
|
|
|
|
|
self.initiator,self.org.name,
|
|
|
|
|
self.initiator .. " joined org " .. self.org.name)
|
|
|
|
|
if self.data.result then self.data.result() end
|
|
|
|
|
self.org:delete_process(self.id)
|
2021-11-22 16:24:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
modpol.modules.join_org = join_org
|