42 end |
42 end |
43 |
43 |
44 -- Enable inline features requested by the client |
44 -- Enable inline features requested by the client |
45 |
45 |
46 local function enable_features(session, bind_request, bind_result) |
46 local function enable_features(session, bind_request, bind_result) |
47 local features = bind_request:get_child("features"); |
|
48 if not features then return; end |
|
49 module:fire_event("enable-bind-features", { |
47 module:fire_event("enable-bind-features", { |
50 session = session; |
48 session = session; |
51 features = features; |
49 request = bind_request; |
52 result = bind_result; |
50 result = bind_result; |
53 }); |
51 }); |
54 end |
52 end |
55 |
53 |
56 -- SASL 2 integration |
54 -- SASL 2 integration |
90 features:tag("feature", { var = "urn:xmpp:carbons:2" }):up(); |
88 features:tag("feature", { var = "urn:xmpp:carbons:2" }):up(); |
91 features:tag("feature", { var = "urn:xmpp:csi:0" }):up(); |
89 features:tag("feature", { var = "urn:xmpp:csi:0" }):up(); |
92 end); |
90 end); |
93 |
91 |
94 module:hook("enable-bind-features", function (event) |
92 module:hook("enable-bind-features", function (event) |
95 local session, features = event.session, event.features; |
93 local session, request = event.session, event.request; |
96 |
94 |
97 -- Carbons |
95 -- Carbons |
98 if features:get_child("enable", "urn:xmpp:carbons:2") then |
96 if request:get_child("enable", "urn:xmpp:carbons:2") then |
99 session.want_carbons = true; |
97 session.want_carbons = true; |
100 event.result:tag("enabled", { xmlns = "urn:xmpp:carbons:2" }):up(); |
98 event.result:tag("enabled", { xmlns = "urn:xmpp:carbons:2" }):up(); |
101 end |
99 end |
102 |
100 |
103 -- CSI |
101 -- CSI |
104 local csi_state_tag = features:child_with_ns("urn:xmpp:csi:0"); |
102 local csi_state_tag = request:child_with_ns("urn:xmpp:csi:0"); |
105 if csi_state_tag then |
103 if csi_state_tag then |
106 session.state = csi_state_tag.name; |
104 session.state = csi_state_tag.name; |
107 end |
105 end |
108 end, 10); |
106 end, 10); |