Software /
code /
prosody
Comparison
plugins/mod_scansion_record.lua @ 9618:d6e6e1fb7ef0 0.11
mod_scansion_record: Discard from/to where these are implicitly the sessions full JID
Makes it easier to clean up recordings and change JIDs etc
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Nov 2018 16:32:43 +0100 |
parent | 9373:1a69803d5d5d |
child | 9619:7172077c0a53 |
comparison
equal
deleted
inserted
replaced
9616:61376a3c0c1d | 9618:d6e6e1fb7ef0 |
---|---|
4 | 4 |
5 local filters = require "util.filters"; | 5 local filters = require "util.filters"; |
6 local id = require "util.id"; | 6 local id = require "util.id"; |
7 local dt = require "util.datetime"; | 7 local dt = require "util.datetime"; |
8 local dm = require "util.datamanager"; | 8 local dm = require "util.datamanager"; |
9 local st = require "util.stanza"; | |
9 | 10 |
10 local record_id = id.medium():lower(); | 11 local record_id = id.medium():lower(); |
11 local record_date = os.date("%Y%b%d"):lower(); | 12 local record_date = os.date("%Y%b%d"):lower(); |
12 local header_file = dm.getpath(record_id, "scansion", record_date, "scs", true); | 13 local header_file = dm.getpath(record_id, "scansion", record_date, "scs", true); |
13 local record_file = dm.getpath(record_id, "scansion", record_date, "log", true); | 14 local record_file = dm.getpath(record_id, "scansion", record_date, "log", true); |
39 record(session.scansion_id.." "..verb..":\n\t"..tostring(stanza).."\n\n"); | 40 record(session.scansion_id.." "..verb..":\n\t"..tostring(stanza).."\n\n"); |
40 end | 41 end |
41 | 42 |
42 local function record_stanza_in(stanza, session) | 43 local function record_stanza_in(stanza, session) |
43 if stanza.attr.xmlns == nil then | 44 if stanza.attr.xmlns == nil then |
44 record_stanza(stanza, session, "sends") | 45 local copy = st.clone(stanza); |
46 copy.attr.from = nil; | |
47 record_stanza(copy, session, "sends") | |
45 end | 48 end |
46 return stanza; | 49 return stanza; |
47 end | 50 end |
48 | 51 |
49 local function record_stanza_out(stanza, session) | 52 local function record_stanza_out(stanza, session) |
50 if stanza.attr.xmlns == nil then | 53 if stanza.attr.xmlns == nil then |
51 if not (stanza.name == "iq" and stanza:get_child("bind", "urn:ietf:params:xml:ns:xmpp-bind")) then | 54 if not (stanza.name == "iq" and stanza:get_child("bind", "urn:ietf:params:xml:ns:xmpp-bind")) then |
52 record_stanza(stanza, session, "receives"); | 55 local copy = st.clone(stanza); |
56 if copy.attr.to == session.full_jid then | |
57 copy.attr.to = nil; | |
58 end | |
59 record_stanza(copy, session, "receives"); | |
53 end | 60 end |
54 end | 61 end |
55 return stanza; | 62 return stanza; |
56 end | 63 end |
57 | 64 |