Mercurial > prosody-modules
annotate mod_http_status/mod_http_status.lua @ 5170:4d6af8950016
mod_muc_moderation: Derive role from reserved nickname if occupant
When using a different client to moderate than the one used to
participate in the chat, e.g. a command line tool like clix, there's no
occupant and no role to use in the permission check. Previously the
default role based on affiliation was used. Now if you are present in
the room using your reserved nick, the role you have there is used in
the permission check instead of the default affiliation-derived role.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 19 Feb 2023 18:17:37 +0100 |
parents | 6af2d74daa15 |
children | e274431bf4ce |
rev | line source |
---|---|
5161
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 module:set_global(); |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local json = require "util.json"; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local datetime = require "util.datetime".datetime; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local modulemanager = require "core.modulemanager"; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 module:provides("http", { |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 route = { |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 GET = function(event) |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local request, response = event.request, event.response; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 response.headers.content_type = "application/json"; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 local resp = { ["*"] = true }; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 for host in pairs(prosody.hosts) do |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 resp[host] = true; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 end |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 for host in pairs(resp) do |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 local hostmods = {}; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 local mods = modulemanager.get_modules(host); |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 for mod_name, mod in pairs(mods) do |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 hostmods[mod_name] = { |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 type = mod.module.status_type; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 message = mod.module.status_message; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 time = datetime(math.floor(mod.module.status_time)); |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 }; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 resp[host] = hostmods; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 end |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 return json.encode(resp); |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 end; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 }; |
6af2d74daa15
mod_http_status: Report module statuses
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 }); |