Mercurial > prosody-modules
changeset 4431:8b69e0b56db2
mod_groups_shell: add an admin shell command for updating bookmarks
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Fri, 05 Feb 2021 15:45:55 +0100 (2021-02-05) |
parents | 71c495fa03f3 |
children | e83284d4d5c2 |
files | mod_groups_shell/mod_groups_shell.lua |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_groups_shell/mod_groups_shell.lua Fri Feb 05 15:45:55 2021 +0100 @@ -0,0 +1,31 @@ +module:set_global() + +local modulemanager = require "core.modulemanager"; + +local shell_env = module:shared("/*/admin_shell/env") + +shell_env.groups = {}; + +function shell_env.groups:sync_group(host, group_id) + local print = self.session.print; + + if not host then + return false, "host not given" + end + + local mod_groups = modulemanager.get_module(host, "groups_internal") + if not mod_groups then + return false, host .. " does not have mod_groups_internal loaded" + end + + if not group_id then + return false, "group id not given" + end + + local ok, err = mod_groups.emit_member_events(group_id) + if ok then + return true, "Synchronised members" + else + return ok, err + end +end