join_org.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --- Adds a user to org
  2. -- @module join_org
  3. join_org = {}
  4. join_org.setup = {
  5. name = "Join Org",
  6. slug = "join_org",
  7. desc = "If consent process is passed, initiator joins this org."
  8. }
  9. --- Adds the user to the org
  10. -- @function join_org.initiate
  11. -- @param result Callback if this module is embedded in other modules
  12. function join_org.initiate(result)
  13. modpol.interactions.binary_poll_user(
  14. initiator,
  15. "Would you like to join " .. org.name,
  16. function (resp)
  17. if resp == "Yes" then
  18. self.org:add_member(self.initiator)
  19. end
  20. end
  21. )
  22. for i, member in ipairs(self.org.members) do
  23. self.org:add_pending_action(
  24. member,
  25. function ()
  26. modpol.interactions.binary_poll_user(
  27. member,
  28. "Let " .. initiator .. " join " .. org.name .. "?",
  29. function (resp)
  30. end
  31. )
  32. end
  33. )
  34. end
  35. if result then result() end
  36. end
  37. modpol.modules.join_org = join_org