Mercurial > prosody-modules
comparison mod_easy_invite/mod_easy_invite.lua @ 4022:3ac31ddab7eb
mod_easy_invite: Add commands to telnet console
Handy if all you have is SSH access and no ad-hoc capable client
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 16 May 2020 19:48:26 +0200 |
parents | 14028430638b |
children | 7e2db4d61f6c |
comparison
equal
deleted
inserted
replaced
4021:1925d63eec6b | 4022:3ac31ddab7eb |
---|---|
182 | 182 |
183 module:log("debug", "Creating mutual subscription between %s and %s", inviter_username, contact_username); | 183 module:log("debug", "Creating mutual subscription between %s and %s", inviter_username, contact_username); |
184 subscribe_both(module.host, inviter_username, contact_username); | 184 subscribe_both(module.host, inviter_username, contact_username); |
185 end); | 185 end); |
186 | 186 |
187 do | |
188 -- Telnet command | |
189 -- Since the telnet console is global this overwrites the command for | |
190 -- each host it's loaded on, but this should be fine. | |
191 | |
192 local get_module = require "core.modulemanager".get_module; | |
193 | |
194 local console_env = module:shared("/*/admin_telnet/env"); | |
195 | |
196 -- luacheck: ignore 212/self | |
197 console_env.invite = {}; | |
198 function console_env.invite:create_account(user_jid) | |
199 local username, host = jid_split(user_jid); | |
200 local mod_invites, err = get_module(host, "invites"); | |
201 if not mod_invites then return nil, err or "mod_invites not loaded on this host"; end | |
202 local invite, err = mod_invites.create_account(username); | |
203 if not invite then return nil, err; end | |
204 return true, invite.uri; | |
205 end | |
206 | |
207 function console_env.invite:create_contact(user_jid, allow_registration) | |
208 local username, host = jid_split(user_jid); | |
209 local mod_invites, err = get_module(host, "invites"); | |
210 if not mod_invites then return nil, err or "mod_invites not loaded on this host"; end | |
211 local invite, err = mod_invites.create_contact(username, allow_registration); | |
212 if not invite then return nil, err; end | |
213 return true, invite.uri; | |
214 end | |
215 end | |
187 | 216 |
188 local sm = require "core.storagemanager"; | 217 local sm = require "core.storagemanager"; |
189 function module.command(arg) | 218 function module.command(arg) |
190 if #arg < 2 or arg[2] ~= "generate" then | 219 if #arg < 2 or arg[2] ~= "generate" then |
191 print("usage: prosodyctl mod_easy_invite example.net generate"); | 220 print("usage: prosodyctl mod_easy_invite example.net generate"); |