Mercurial > prosody-modules
comparison mod_http_xep227/mod_http_xep227.lua @ 4867:9d29467f4d5b
mod_http_xep227: Fix luacheck warnings
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 15 Jan 2022 13:46:34 +0000 |
parents | bd0a1f917d98 |
children | 57311c545013 |
comparison
equal
deleted
inserted
replaced
4866:a1181413a0eb | 4867:9d29467f4d5b |
---|---|
70 -- Fiddling to handle the 'pep_data' storage config override | 70 -- Fiddling to handle the 'pep_data' storage config override |
71 if store_name:find("pep_", 1, true) == 1 then | 71 if store_name:find("pep_", 1, true) == 1 then |
72 store_name = "pep_data"; | 72 store_name = "pep_data"; |
73 end | 73 end |
74 -- Return driver | 74 -- Return driver |
75 return sm.get_driver(session.host, driver_store_name); | 75 return sm.get_driver(host, store_name); |
76 end | 76 end |
77 | 77 |
78 local function handle_export_227(event) | 78 local function handle_export_227(event) |
79 local session = assert(event.session, "No session found"); | 79 local session = assert(event.session, "No session found"); |
80 local xep227_driver = sm.load_driver(session.host, "xep0227"); | 80 local xep227_driver = sm.load_driver(session.host, "xep0227"); |
145 if not xml_data or xml_data.name ~= "server-data" | 145 if not xml_data or xml_data.name ~= "server-data" |
146 or xml_data.attr.xmlns ~= "urn:xmpp:pie:0" then | 146 or xml_data.attr.xmlns ~= "urn:xmpp:pie:0" then |
147 return false; | 147 return false; |
148 end | 148 end |
149 -- Looks like 227, but check it has at least one host + user element | 149 -- Looks like 227, but check it has at least one host + user element |
150 return not not input_xml_parsed:find("host/user"); | 150 return not not xml_data:find("host/user"); |
151 end | 151 end |
152 | 152 |
153 local function handle_import_227(event) | 153 local function handle_import_227(event) |
154 local session = assert(event.session, "No session found"); | 154 local session = assert(event.session, "No session found"); |
155 local username = session.username; | 155 local username = session.username; |
156 | 156 |
157 local input_xml_raw = event.request.body; | 157 local input_xml_raw = event.request.body; |
158 local input_xml_parsed = xml.parse(input_xml_raw); | 158 local input_xml_parsed = xml.parse(input_xml_raw); |
159 | 159 |
160 -- Some sanity checks | 160 -- Some sanity checks |
161 if not input_xml_parsed or not is_looking_like_227(input_xml_parsed) then | 161 if not input_xml_parsed or not is_looking_like_xep227(input_xml_parsed) then |
162 module:log("warn", "No data to import"); | 162 module:log("warn", "No data to import"); |
163 return 422; | 163 return 422; |
164 end | 164 end |
165 | 165 |
166 -- Set the host and username of the import to the new account's user/host | 166 -- Set the host and username of the import to the new account's user/host |