Mercurial > prosody-modules
comparison mod_storage_metronome_readonly/mod_storage_metronome_readonly.lua @ 6143:44f77f4f653a
mod_storage_metronome_readonly: Revert non-working is_muc hack, the correct with is "message<groupchat"
| author | Link Mauve <linkmauve@linkmauve.fr> |
|---|---|
| date | Tue, 28 Jan 2025 01:58:45 +0100 |
| parents | ec0e9d4f2275 |
| children | 983549664bd4 |
comparison
equal
deleted
inserted
replaced
| 6142:ec0e9d4f2275 | 6143:44f77f4f653a |
|---|---|
| 162 store = self.store; | 162 store = self.store; |
| 163 end | 163 end |
| 164 return datamanager.users(host, store, self.type); | 164 return datamanager.users(host, store, self.type); |
| 165 end | 165 end |
| 166 | 166 |
| 167 local function parse_logs(logs, is_muc) | 167 local function parse_logs(logs) |
| 168 local iter = ipairs(logs); | 168 local iter = ipairs(logs); |
| 169 local i = 0; | 169 local i = 0; |
| 170 local message; | 170 local message; |
| 171 return function() | 171 return function() |
| 172 i, message = iter(logs, i); | 172 i, message = iter(logs, i); |
| 173 if not message then | 173 if not message then |
| 174 return; | 174 return; |
| 175 end | 175 end |
| 176 | 176 |
| 177 local with; | 177 local with; |
| 178 if is_muc then | 178 local bare_to = message["bare_to"]; |
| 179 with = message["resource"]; | 179 local bare_from = message["bare_from"]; |
| 180 if jid == bare_to then | |
| 181 -- received | |
| 182 with = bare_from; | |
| 180 else | 183 else |
| 181 local bare_to = message["bare_to"]; | 184 -- sent |
| 182 local bare_from = message["bare_from"]; | 185 with = bare_to; |
| 183 if jid == bare_to then | |
| 184 -- received | |
| 185 with = bare_from; | |
| 186 else | |
| 187 -- sent | |
| 188 with = bare_to; | |
| 189 end | |
| 190 end | 186 end |
| 191 | 187 |
| 192 local to = message["to"]; | 188 local to = message["to"]; |
| 193 local from = message["from"]; | 189 local from = message["from"]; |
| 194 local id = message["id"]; | 190 local id = message["id"]; |
| 345 local success, data = pcall(get_data); | 341 local success, data = pcall(get_data); |
| 346 if not success then | 342 if not success then |
| 347 module:log("error", "Unable to load metronome storage"); | 343 module:log("error", "Unable to load metronome storage"); |
| 348 return nil, "Error reading storage"; | 344 return nil, "Error reading storage"; |
| 349 end | 345 end |
| 350 for key, item, when, with in parse_logs(data, true) do | 346 for key, item, when in parse_logs(data) do |
| 351 table.insert(list, {key, item, when, with}); | 347 table.insert(list, {key, item, when}); |
| 352 end | 348 end |
| 353 end | 349 end |
| 354 end | 350 end |
| 355 end | 351 end |
| 356 | 352 |
| 366 if list.close then | 362 if list.close then |
| 367 list:close(); | 363 list:close(); |
| 368 end | 364 end |
| 369 return | 365 return |
| 370 end | 366 end |
| 371 return item[1], item[2], item[3], item[4]; | 367 return item[1], item[2], item[3], "message<groupchat" |
| 372 end | 368 end |
| 373 | 369 |
| 374 else | 370 else |
| 375 return nil, "unsupported-store"; | 371 return nil, "unsupported-store"; |
| 376 end | 372 end |
