Mercurial > prosody-hg
comparison plugins/mod_muc_unique.lua @ 8878:7c3e16fdaf1d
mod_muc_unique: Use util.id for more compact identifiers
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 06 Jun 2018 13:33:37 +0200 |
| parents | 5fd6c739e9bf |
| children | 74b9e05af71e |
comparison
equal
deleted
inserted
replaced
| 8877:9182398c64b9 | 8878:7c3e16fdaf1d |
|---|---|
| 1 -- XEP-0307: Unique Room Names for Multi-User Chat | 1 -- XEP-0307: Unique Room Names for Multi-User Chat |
| 2 local st = require "util.stanza"; | 2 local st = require "util.stanza"; |
| 3 local uuid_gen = require "util.uuid".generate; | 3 local unique_name = require "util.id".medium; |
| 4 module:add_feature "http://jabber.org/protocol/muc#unique" | 4 module:add_feature "http://jabber.org/protocol/muc#unique" |
| 5 module:hook("iq-get/host/http://jabber.org/protocol/muc#unique:unique", function(event) | 5 module:hook("iq-get/host/http://jabber.org/protocol/muc#unique:unique", function(event) |
| 6 local origin, stanza = event.origin, event.stanza; | 6 local origin, stanza = event.origin, event.stanza; |
| 7 origin.send(st.reply(stanza) | 7 origin.send(st.reply(stanza) |
| 8 :tag("unique", {xmlns = "http://jabber.org/protocol/muc#unique"}) | 8 :tag("unique", {xmlns = "http://jabber.org/protocol/muc#unique"}) |
| 9 :text(uuid_gen()) -- FIXME Random UUIDs can theoretically have collisions | 9 :text(unique_name():lower()) |
| 10 ); | 10 ); |
| 11 return true; | 11 return true; |
| 12 end,-1); | 12 end,-1); |
