# HG changeset patch # User Kim Alvefur # Date 1422628734 -3600 # Node ID bae84401a02c14c49631ee08565cd008dfb906ae # Parent 0ef7ca5276a15c47f2c5960993226dd3f8127b8e sessionmanager: Add pre-resource-bind event that would let plugins have a say in resource binding diff -r 0ef7ca5276a1 -r bae84401a02c core/sessionmanager.lua --- a/core/sessionmanager.lua Mon Jan 26 15:25:16 2015 +0100 +++ b/core/sessionmanager.lua Fri Jan 30 15:38:54 2015 +0100 @@ -117,6 +117,16 @@ if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end -- We don't support binding multiple resources + local event_payload = { session = session, resource = resource }; + if hosts[session.host].events.fire_event("pre-resource-bind", event_payload) == false then + local err = event_payload.error; + if err then return nil, err.type, err.condition, err.text; end + return nil, "cancel", "not-allowed"; + else + -- In case a plugin wants to poke at it + resource = event_payload.resource; + end + resource = resourceprep(resource); resource = resource ~= "" and resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing