Mercurial > prosody-modules
comparison mod_groups_internal/mod_groups_internal.lua @ 4399:846b7af5588c
mod_groups_internal: send invite to new members of groups
| author | Jonas Schäfer <jonas@wielicki.name> |
|---|---|
| date | Tue, 26 Jan 2021 17:28:26 +0100 |
| parents | e5792ca1d704 |
| children | 31470a256851 |
comparison
equal
deleted
inserted
replaced
| 4398:a16b689525d7 | 4399:846b7af5588c |
|---|---|
| 1 local rostermanager = require"core.rostermanager"; | 1 local rostermanager = require"core.rostermanager"; |
| 2 local modulemanager = require"core.modulemanager"; | 2 local modulemanager = require"core.modulemanager"; |
| 3 local id = require "util.id"; | 3 local id = require "util.id"; |
| 4 local jid = require "util.jid"; | 4 local jid = require "util.jid"; |
| 5 local st = require "util.stanza"; | |
| 5 local jid_join = jid.join; | 6 local jid_join = jid.join; |
| 6 local host = module.host; | 7 local host = module.host; |
| 7 | 8 |
| 8 local group_info_store = module:open_store("group_info"); | 9 local group_info_store = module:open_store("group_info"); |
| 9 local group_members_store = module:open_store("groups"); | 10 local group_members_store = module:open_store("groups"); |
| 203 if group_info.muc_jid then | 204 if group_info.muc_jid then |
| 204 local room = muc_host.get_room_from_jid(group_info.muc_jid); | 205 local room = muc_host.get_room_from_jid(group_info.muc_jid); |
| 205 if room then | 206 if room then |
| 206 local user_jid = username .. "@" .. host; | 207 local user_jid = username .. "@" .. host; |
| 207 room:set_affiliation(true, user_jid, "member") | 208 room:set_affiliation(true, user_jid, "member") |
| 209 module:send(st.message( | |
| 210 { from = group_info.muc_jid, to = user_jid } | |
| 211 ):tag("x", { | |
| 212 xmlns = "jabber:x:conference", | |
| 213 jid = group_info.muc_jid | |
| 214 }):up()); | |
| 215 module:log("debug", "set user %s to be member in %s and sent invite", username, group_info.muc_jid) | |
| 208 else | 216 else |
| 209 module:log("warning", "failed to update affiliation for %s in %s", username, group_info.muc_jid) | 217 module:log("warning", "failed to update affiliation for %s in %s", username, group_info.muc_jid) |
| 210 end | 218 end |
| 211 end | 219 end |
| 212 if not delay_update then | 220 if not delay_update then |
